The XMLCONCAT function returns a sequence containing the concatenation of a variable number of XML input arguments.
The schema is SYSIBM. The function name cannot be specified as a qualified name.
The data type of the result is XML. The result is an XML sequence containing the concatenation of the non-null input XML values. Null values in the input are ignored. If the result of any XML-expression can be null, the result can be null; if the result of every input value is null, the result is the null value.
SELECT XMLCONCAT(
XMLCOMMENT(
'Confirm these employees are on track for their product schedule'
),
XMLELEMENT(
NAME "Department",
XMLATTRIBUTES(
E.WORKDEPT AS "name"
),
XMLAGG(
XMLELEMENT(
NAME "emp", E.FIRSTNME
)
ORDER BY E.FIRSTNME
)
)
)
FROM EMPLOYEE E
WHERE E.WORKDEPT IN ('A00', 'B01')
GROUP BY E.WORKDEPT
This query produces the
following result: <!--Confirm these employees are on track for their product schedule-->
<Department name="A00">
<emp>CHRISTINE</emp>
<emp>DIAN</emp>
<emp>GREG</emp>
<emp>SEAN</emp>
<emp>VINCENZO</emp>
</Department>
<!--Confirm these employees are on track for their product schedule-->
<Department name="B01">
<emp>MICHAEL</emp>
</Department>