Contents Index Obtaining query results as XML FOR XML and binary data

ASA SQL User's Guide
  Using XML in the Database
    Obtaining query results as XML

Using the FOR XML clause to retrieve query results as XML


Adaptive Server Anywhere allows you to execute a SQL query against your database and return the results as an XML document by using the FOR XML clause in your SELECT statement. The XML document is of type XML.

For information about the XML data type, see XML data type [Character].

The FOR XML clause can be used in any SELECT statement, including subqueries, queries with a GROUP BY clause or aggregate functions, and view definitions.

For examples of how the FOR XML clause can be used, see FOR XML examples.

Adaptive Server Anywhere does not generate a schema for XML documents generated by the FOR XML clause.

Within the FOR XML clause, you specify one of three XML modes that control the format of the XML that is generated:

The following sections describe the behavior of all three modes of the FOR XML clause regarding binary data, NULL values, and invalid XML names, as well as providing examples of how the FOR XML clause can be used.


FOR XML and binary data
FOR XML and NULL values
Invalid column names
FOR XML examples

Contents Index Obtaining query results as XML FOR XML and binary data