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. 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 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. Selected by default.
Root Label 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. Deselected by default. Disabled if Include Root is not selected.
Row Label Name of the row element (default is row).
Namespace Specifies a URL to be included as the xmlns attribute.
Schema Location Specifies a URL to be included as the xsi:SchemaLocation (or xsi:noNamespaceSchemaLocation if Namespace is not specified) attribute.
Format Include formatting for newline and tab characters. Selected by default.
Header Include 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".

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

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.