Select for XML Statements

Sybase WorkSpace supports creation of select…for xml statements when using an ASE or SQL Anywhere 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. When you select Return Results as XML, Sybase WorkSpace appends FOR XML to the generated select statement. The XML view also contains options specific to SQL Anywhere or ASE for controlling the results and formatting of the returned XML code.

Note: Only SQL Anywhere and ASE are supported. If you attempt to use another database, the message XML results not supported for current database displays.
Table 1. SQL Anywhere XML view options
Option Value/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.

Table 2. ASE XML view options
Option Value/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 Root Include a root element in the results (default).
Root Label Specify the label for the root element (default is resultset). Disabled if Include Root is not selected.
Include Select Statement Include the SQL query in the root element. Disabled if Include Root is not selected.
Row Label Specify the name of the row element (default is row).
Namespace Include a URL as the xmlns attribute.
Schema Location Include a URL as the xsi:SchemaLocation (or xsi:noNamespaceSchemaLocation if Namespace is not specified) attribute.
Format Include formatting for newline and tab characters.
Header Include an XML header.
Null Style Attribute – include null columns as empty elements with the xsi:null=true attribute.

Omit (default)– omit null columns from the row that contains them.

Disabled if Columns As = "Attributes".

Related concepts
Real-Time Messaging Services
Mapping Functions
Related tasks
Sending a Message to a JMS Queue
Receiving a Message from a JMS Queue
Sending a Message to a WebSphere MQ Queue
Receiving a Message from a WebSphere MQ Queue
Publishing a Message to a Topic
Subscribing to a Topic
Consuming a Message from a Topic
Unsubscribing from a Topic
Registering a Subscription
Parsing an XML Document
Retrieving XML Message Properties


Created June 25, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com