ASA SQL Reference
SQL Functions
Alphabetical list of functions
Generates a forest of XML elements.
XMLFOREST ( element-content-expression [ AS element-name ],... )
element-content-expression A string. An element is generated for each element-content-expression argument that is specified. The element-content-expression value becomes the content of the element. For example, if you specify the emp_id column from the employee table for this argument, then an <emp_id> element containing an emp_id value is generated for each value in the table.
Specify the element-name argument if you wish to assign a name other than the element-content-expression to the element, otherwise the element name defaults to the element-content-expression name.
Produces a forest of XML elements. In the unparsed XML document, a forest refers to the multiple root nodes within the document. When all of the arguments to XMLFOREST are NULL, a NULL value is returned. If only some values are NULL, the NULL values are omitted from the result. Element content is always quoted unless the data type is XML. You cannot specify attributes using XMLFOREST. Use the XMLELEMENT function if you wish to specify attributes for generated elements.
For more information about the XMLELEMENT function, see XMLELEMENT function [String].
Element names are quoted unless the data type is XML.
If you require a well-formed XML document, you must ensure that your query is written so that a single root element is generated.
Data in BINARY, LONG BINARY, IMAGE, and VARBINARY columns is automatically returned in base64-encoded format when you execute a query that contains XMLFOREST.
Part of the SQL/XML draft standard.
Sybase Not supported by Adaptive Server Enterprise.
The following statement produces an XML element for the first and last name of each employee.
SELECT emp_id, XMLFOREST( emp_fname, emp_lname ) AS "Employee Name" FROM employee