17.10 - Examples: Using XMLDOCUMENT to Create an XML Document Node From an XML Type Value - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1140-171K
Language
English (United States)
The following query returns an XML document node with a child element named 'Customer':
SELECT XMLDOCUMENT(new XML('<Customer/>'));
Query result:
XMLDOCUMENT( NEW XML('<Customer/>') RETURNING SEQUENCE )
--------------------------------------------------------
<Customer></Customer>
The following query returns an XML document node with two child elements named 'Name' and 'Address'. This is not a well-formed document according to the XML1.1 specification, but is allowed by the XQuery data model.
SELECT XMLDOCUMENT(XMLQUERY('(<Name/>, <Address/>)') RETURNING CONTENT);
Query result:
XMLDOCUMENT(XMLQUERY('(<Name/>, <Address/>)') RETURNING CONTENT)
----------------------------------------------------------------
<Name></Name><Address></Address>