Select for XML

Sybase WorkSpace supports creation of select…for xml statements when using an ASE or ASA profile through use of an XML view in the SQL Query Editor and Visual SQL. The select...for xml statement returns query results in XML format. The XML view contains a Return Results as XML check box. When this check box is selected, Sybase WorkSpace appends FOR XML to the generated select statement. The XML view also contains options specific to ASA or ASE for controlling the results and formatting of the returned XML code.

XML View Options (ASA)

OptionValue/Description
Columns As

Attributes: show columns as attributes

Elements: show columns as elements

Elements

Each row is returned as an element: each result row is represented as a <row> element.

Each table is returned as an element: an element is created for each table in the select list.

XML View Options (ASE)

OptionValue/Description
Columns As

Attributes: show columns as attributes

Elements: (default) show columns as elements

Results Contain

XML in one row: (default) the result set has one row containing the XML

One row per element: the result set has one row per XML element

Include RootInclude a root element in the results. Selected by default.
Root LabelLabel for the root element (default is resultset). Disabled if Include Root is not selected.
Include Select StatementInclude the SQL query in the root element. Deselected by default. Disabled if Include Root is not selected.
Row LabelName of the row element (default is row).
NamespaceSpecifies a URL to be included as the xmlns attribute.
Schema LocationSpecifies a URL to be included as the xsi:SchemaLocation (or xsi:noNamespaceSchemaLocation if Namespace is not specified) attribute.
FormatInclude formatting for newline and tab characters. Selected by default.
HeaderInclude an XML header. Selected by default.
Null Style

Attribute: null columns should be included as empty elements with the xsi:null=true attribute.

Omit: (default) Null columns should be omitted from the row that contains them.

Disabled if Columns As = "Attributes".

Only ASA and ASE are supported. If you attempt to use another database, the message "XML results not supported for current database" displays.

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