Name

XMLCONCAT — Creates a forest of elements by concatenating a list of XML values

Synopsis

XMLCONCAT ( value_expr1 varchar ,
value_expr2 varchar ,
... ,
value_exprN varchar );

Description

XMLCONCAT accepts a list of XML value expressions as its arguments, and produces a forest of elements by concatenating the XML values that are returned from the same row to make one value. XMLCONCAT works like XMLFOREST , except that XMLCONCAT parameters is a list of XML elements. Null expressions are dropped from the result. If all the value expressions are null, then the function returns NULL.

Parameters

value_expr1

a vector returned by XMLELEMENT , XMLFOREST , or XMLCONCAT functions, or an entity object returned by corresponding functions (e.g. xtree_doc , xquery_eval or path_eval ). In the latter case the entity object must not be an attribute.

Errors

Table24.127.Errors signalled by XMLCONCAT

SQLState Error Code Error Text Description
22003 SR355 Too few arguments for XMLCONCAT There must be at least one argument
22003 SR359 Invalid argument type NVARCHAR (225) for arg N to XMLCONCAT The entity object returned by xpath_eval must not be an attribute
22003 SR360 XMLCONCAT doesn't concatenate attributes The entity object returned by xquery_eval must not be an attribute

Examples

Example24.499.XMLCONCAT() with two parameters

The following example produces an XML elements for the 'FName', 'LName', 'country' and 'nationality', concatenates the result, and creates a one-column result set:

select XMLCONCAT (
        XMLELEMENT ('FName', "FirstName"),
        XMLELEMENT ('LName', "LastName"),
        xquery_eval('//country', xtree_doc('<a><country>USA</country></a>')),
        xpath_eval('//nationality', xtree_doc('<a><nationality>RUSSIAN</nationality></a>')))
from "Demo"."demo"."Employees";

callret
VARCHAR
_______________________________________________________________________________
<FName>Nancy</FName><LName>Davolio</LName><country>USA</country><nationality>RUSSIAN</nationality>
<FName>Andrew</FName><LName>Fuller</LName><country>USA</country><nationality>RUSSIAN</nationality>

. . .

<FName>Anne</FName><LName>Dodsworth</LName><country>USA</country><nationality>RUSSIAN</nationality>
9 Rows.