XMLCONCAT is an SQL/XML scalar function defined by the SQL:2003 standard that merges multiple XML values into one. Each argument must be of type XML. Null arguments are ignored; if every argument is NULL, the function returns NULL. XMLCONCAT performs a shallow concatenation - it simply appends the node sequences of the inputs without wrapping them in a new root element or preserving XML declarations. As a result, the output is a well-formed XML forest only if the caller ensures the combined nodes form a valid document or are later wrapped (for example, with XMLELEMENT). Because no implicit casting from text to XML occurs in most databases, string literals usually need an explicit cast to XML. The function runs in the SQL engine, making it faster and more secure than concatenating XML in client code.
- xml_valueN
(XML) - One or more XML expressions to be concatenated. Unlimited positional parameters are allowed.- Returns
(XML) - A single XML value representing the concatenated input.XMLELEMENT, XMLFOREST, XMLAGG, XMLQUERY, XMLSERIALIZE, CONCAT
SQL:2003 (SQL/XML)
No. It simply appends the node sequences of its inputs. Use XMLELEMENT to wrap the result if you need a single root.
NULL arguments are skipped. If all arguments are NULL, XMLCONCAT returns NULL.
XMLCONCAT works on typed XML values, preserving node structure and ensuring the output remains valid XML. String functions do not validate XML.
Wrap the XMLCONCAT call inside an XMLELEMENT (or similar) to provide a single root, or guarantee that the concatenated fragments already share one.