New XML Type Instances | XML Data Type | Teradata Vantage - New XML Type Instances - Analytics Database - Teradata Vantage

XML Data Type

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
tkc1628112506748.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dgs1472251600184
lifecycle
latest
Product Category
Teradata Vantageā„¢
You can construct XML type instances using the following:
  • The NEW operator
  • The CREATEXML function
  • The XMLPARSE function

The following example uses the NEW operator to construct an XML type instance from the text representation of the XML document in the customerText.customerXMLText column.

If the XML is loaded in its text representation into a VARCHAR or CLOB column named customerXMLText in the customerText table, it can be used to construct XML type instances:

SELECT customerID, (NEW XML(customerXMLText)).XMLEXTRACT('/Customer/Address', NULL)
FROM customerText;

Query result:

customerID  NEW XML(customerXMLText).XMLEXTRACT('/Customer/Address', Null)
--------------------------------------------------------------------------
         1  <Address>100 1st Street, San Francisco, CA 94118</Address>

The following example uses the CREATEXML function to construct an XML type instance from the text representation of the XML document in the customerText.customerXMLText column:

SELECT customerID, (CREATEXML(customerXMLText)).XMLEXTRACT('/Customer/Address', NULL)
FROM customerText;

Query result:

customerID  CREATEXML(customerXMLText).XMLEXTRACT('/Customer/Address', Null)
----------------------------------------------------------------------------
         1  <Address>100 1st Street, San Francisco, CA 94118</Address>

The customerText.customerXMLText column can be of VARCHAR, CLOB, or BLOB type.

XML type instances are also generated by other operations such as casts and invocation of methods and functions that return results as XML type values.