Example: Using XMLEXTRACT to Evaluate a Query Against an XML Instance - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
kxe1590704060061.ditamap
dita:ditavalPath
kxe1590704060061.ditaval
dita:id
B035-1140
lifecycle
previous
Product Category
Teradata Vantageā„¢

In this example, the XPath expression (in bold) is extracting the Address elements in the XML documents for the customer named John Hancock.

SELECT customerXML.XMLEXTRACT('/Customer[Name="John Hancock"]/Address', '')
FROM customer
WHERE customerID = 1;

Query result:

customerXML.XMLEXTRACT('/Customer[Name="John Hancock"]/Address', '')
--------------------------------------------------------------------
<Address>100 1st Street, San Francisco, CA 94118</Address>