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
The following examples show how the FOR XML clause can be used in a SELECT statement.
The following example shows how the FOR XML clause can be used in a subquery:
SELECT XMLELEMENT( NAME root, (SELECT * FROM employee FOR XML RAW))
The following example shows how the FOR XML clause can be used in a query with a GROUP BY clause and aggregate function:
SELECT name, AVG(unit_price) AS Price FROM product GROUP BY name FOR XML RAW
The following example shows how the FOR XML clause can be used in a view definition:
CREATE VIEW emp_dept AS SELECT emp_lname, emp_fname, dept_name FROM employee JOIN department ON employee.dept_id = department.dept_id FOR XML AUTO