The genxmlelem() and genxmlelemclob() XML functions

These functions publish each element in the document separately.

Purpose

These functions return each column value as separate elements, in contrast to genxml(), which returns column values as attributes of the row element.

The genxmlelem() syntax

Read syntax diagramSkip visual syntax diagram
>>-genxmlelem--(--row--,--element--)---------------------------><

The genxmlelemclob() syntax

Read syntax diagramSkip visual syntax diagram
>>-genxmlelemclob--(--row--,--element--)-----------------------><

Parameters

row
The rows and columns to return.
element
The name of the element that contains the result set.

Example 1

This example uses the table Table 1. The first parameter specifies the table name to retrieve all columns from the table. The second parameter specifies to place the output in an XML tag, classes.
SELECT genxmlelem(classes, “classes”) from classes where classid = 1;
The query returns one row:
<classes>
<row>
<classid>1</classid>
<class>125</class>
<subject>Chemistry</subject>
</row>
</classes>

Example 2

This query returns a list of all employees from the employee table.
SELECT genxmlelemclob(employee, “employee”) FROM employee;
<employee>
<row>
<givenname>Roy</givenname>
<familyname>Connor</familyname>
<address>
<address1>123 First Street</address1>
<city>Denver</city>
<state/>CO</state>
<zipcode>80111</zipcode>
</address>
<phone>303-555-1212</phone>
</row>
.
.
.
</employee>

Copyright© 2019 HCL Technologies Limited