XMLTABLE
The XMLTABLE function uses XQuery to produce tabular output. The XMLTABLE function is implicitly a nested table and may be correlated to the preceding FROM clause entries. XMLTABLE is part of the SQL/XML 2006 specification.
Usage
XMLTABLE([<NSP>,] xquery-expression [<PASSING>] [COLUMNS <COLUMN>, ... )] AS name
COLUMN := name (FOR ORDINALITY | (datatype [DEFAULT expression] [PATH string]))
See XMLELEMENT for the definition of NSP - XMLNAMESPACES;
See also XMLQUERY.
See also XQuery Optimization.
Parameters
The optional
XMLNAMESPACESclause specifies the namespaces for use in the XQuery andCOLUMNpath expressions;The XQuery-expression should be a valid XQuery. Each sequence item returned by the XQuery will be used to create a row of values as defined by the
COLUMNSclause;If
COLUMNSis not specified, then that is the same as having theCOLUMNSclause:COLUMNS OBJECT_VALUE XML PATH '.', which returns the entire item as an XML value;A FOR ORDINALITYcolumn is entered as an integer and will return the 1-based item number as its value;Each non-ordinality column specifies a type and optionally a
PATHand aDEFAULTexpression;If
PATHis not specified, the path will be the same as the column name.
Syntax Rules
Only one
A FOR ORDINALITYcolumn may be specified;Column names must contain no duplicates.
Examples
1. Use of PASSING returns 1 row [1]:
        SQL
     
    
 | 
2. As a nested table:
        SQL
     
    
 | 
Array Support
The CData Virtuality Server supports arrays in XMLTABLE. This enables you to load any amount of serial data, which can be interpreted as an array:
        SQL
     
    
 | 
Null Input
When being passed a null value as input, XMLTABLE returns an empty result:
        SQL
     
    
 |