DB2 Scalar functions - XMLROW
The XMLROW function returns an XML value with a single XQuery document node containing one top-level element node.
The schema is SYSIBM. The function name cannot be specified as a qualified name.
By default, each row in the result set is mapped to an XML value as follows:
Assume the following table T1 with columns C1 and C2 that contain numeric data stored in a relational format:
C1 C2 ----------- ----------- 1 2 - 2 1 - - - 4 record(s) selected.
SELECT XMLROW(C1, C2) FROM T1
<row><C1>1</C1><C2>2</C2></row> <row><C2>2</C2></row> <row><C1>1</C1></row> 4 record(s) selected.
SELECT XMLROW(C1, C2 OPTION AS ATTRIBUTES) FROM T1
<row C1="1" C2="2"/> <row C2="2"/> <row C1="1"/> 4 record(s) selected.
SELECT XMLROW( C1 AS "column1", C2 AS "column2", C1+C2 AS "total" OPTION ROW "entry") FROM T1
<entry><column1>1</column1><column2>2</column2><total>3</total></entry> <entry><column2>2</column2></entry> <entry><column1>1</column1></entry> 4 record(s) selected.