Example: XQuery Query - 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
Language
English (United States)
Last Update
2023-10-30
dita:mapPath
tkc1628112506748.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dgs1472251600184
lifecycle
latest
Product Category
Teradata Vantageā„¢

You can use the XMLQUERY function to evaluate XQuery 1.0 queries against XML values. This example shows a query that is evaluated with the XML value as the context node:

SELECT XMLQUERY('for $i in /Customer/Order/Item
return $i/PartNumber' PASSING customerXML RETURNING CONTENT) as queryres
FROM customer WHERE customerID=1;

The result from the query is:

queryres
=========================
<PartNumber>F54709</PartNumber><PartNumber>Z19743</PartNumber>