Constructing an XML Document from Table Data

The Sybase WorkSpace SQL-to-XML mapping functions enable you to generate SQL that produces a result set in XML format.

  1. From Database Explorer under the ASE connection profile, expand the Procedures and Functions folder or, for triggers, expand the Tables folder and expand the table, then the Triggers folder.

  2. Select the procedure for which you want to construct an XML document. Right-click and select Edit Procedure. Alternatively, select the trigger for which you want to construct an XML document. Right-click and select Edit Trigger.

    The procedure or trigger code appears in SQL Editor.

  3. Place the cursor in the desired location in the code, right-click and select Adaptive Server Enterprise | SQL/XML Wizard. You can also open the SQL/XML Wizard from the SQL/XML Wizard icon on the toolbar. The Select a Wizard dialog appears. Select SQL to XML Mapping functions.

  4. Modify the following input fields.

    Specify the SQL statement

    FieldExample

    Variable or Query

    Click Variable or Query statement to specify a variable or query.

    Variable – Enter a variable in the text field, or choose an existing variable from the menu drop-down. Variable names begin with "@".

    Query – Construct a SQL query in one of two ways:

    Output

    Select one of the following output types:

    • Schema

    • DTD

    • Result set

    • All – output for schema, DTD, and result set

    Click Next to continue.

  5. If you selected All as an output type in the previous screen, you are prompted to provide input variables to store mapping results for result set, schema, and DTD output types. Variable names begin with "@". Once you have provided input variable names, click Next to continue. If you did not select All as an output type, skip this step.

  6. Specify the listed options for the output type or types you selected, and click Finish. For a detailed description of these options, see XML Services in Adaptive Server Enterprise.

  7. The SQL necessary for creating the XML document is displayed in SQL Editor.

Using Mapping Functions

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com