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
XMLNAMESPACES
clause specifies the namespaces for use in the XQuery andCOLUMN
path 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
COLUMNS
clause;If
COLUMNS
is not specified, then that is the same as having theCOLUMNS
clause:COLUMNS OBJECT_VALUE XML PATH '.'
, which returns the entire item as an XML value;A FOR ORDINALITY
column 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
PATH
and aDEFAULT
expression;If
PATH
is not specified, the path will be the same as the column name.
Syntax Rules
Only one
A FOR ORDINALITY
column 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
|