16.20 - Example: XQuery Query - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ XML Data Type

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1140-162K
Language
English (United States)

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>