Example: Using XMLTABLE Without the COLUMNS Clause - Advanced SQL Engine - Teradata Database

XML Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
amr1556233250442.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1140
lifecycle
previous
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<
...