Example: Using XMLTABLE Without the COLUMNS Clause - 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™

If you omit the COLUMNS clause, the items returned by the 'XML_tab_row_pattern' query are returned as a column of XML data type.

SELECT X.*
FROM (SELECT * FROM customer WHERE customerID = 1) AS C,
   XMLTable (
      '/Customer/Order/Item'
      PASSING C.customerXML
   ) AS X ("ItemXML");

Here are partial results from the query. The ellipsis (...) is not part of the query results. It indicates that the query returns additional results that are truncated in the example.

ItemXML
-----------------------------------------------------------------------
<Item ID="001"> <Quantity>10</Quantity> <PartNumber>F54709</
PartNumber> <Description>Motorola S10-HD Bluetooth Stereo
Headphones</Description> <UnitPrice>29.50</UnitPrice> <Price
<Item ID="101"> <Quantity>1</Quantity> <PartNumber>Z19743</
PartNumber> <Description>Motorola Milestone XT800 Cell Phone</
Description> <UnitPrice>139.99</UnitPrice> <Price>139.99<
...