XMLCONCAT scalar function

The XMLCONCAT function returns a sequence containing the concatenation of a variable number of XML input arguments.

Read syntax diagramSkip visual syntax diagramXMLCONCAT(XML-expression ,XML-expression )

The schema is SYSIBM. The function name cannot be specified as a qualified name.

XML-expression
Specifies an expression of data type XML.

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.

Example

Note: XMLCONCAT does not insert blank spaces or new line characters in the output. All example output has been formatted to enhance readability.
Construct a department element for departments A00 and B01, containing a list of employees sorted by first name. Include an introductory comment immediately preceding the department element.
   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>