XMLTABLE
XMLTABLE
Description of the illustration xmltable.gif

Description of the illustration xml_namespaces_clause.gif

Description of the illustration xmltable_options.gif

Description of the illustration xml_passing_clause.gif

Description of the illustration xml_table_column.gif
XMLTable maps the result of an XQuery evaluation into relational rows and columns. You can query the result returned by the function as a virtual relational table using SQL.
-
The
XMLNAMESPACESclause contains a set of XML namespace declarations. These declarations are referenced by the XQuery expression (the evaluatedXQuery_string), which computes the row, and by the XPath expression in thePATHclause ofXML_table_column, which computes the columns for the entireXMLTablefunction. If you want to use qualified names in thePATHexpressions of theCOLUMNSclause, then you need to specify theXMLNAMESPACESclause. -
XQuery_stringis a complete XQuery expression and can include prolog declarations. -
The
exprin theXML_passing_clauseis an expression returning anXMLTypeor an instance of a SQL scalar data type that is used as the context for evaluating the XQuery expression. You can specify only oneexprin thePASSINGclause without an identifier. The result of evaluating eachexpris bound to the corresponding identifier in theXQuery_string. If anyexprthat is not followed by anASclause, then the result of evaluating that expression is used as the context item for evaluating theXQuery_string. -
The optional
COLUMNSclause defines the columns of the virtual table to be created byXMLTable.-
If you omit the
COLUMNSclause, thenXMLTablereturns a row with a singleXMLTypepseudocolumn namedCOLUMN_VALUE. -
The
datatypeis required unlessXMLTableis used with XML schema-based storage ofXMLType,datatype. In this case, if you omitdatatype, Oracle XML DB infers the data type from the XML schema. If the database is unable to determine the proper type for a node, then a default type ofVARCHAR2(4000)is used. -
FORORDINALITYspecifies that column is to be a column of generated row numbers. There must be at most oneFORORDINALITYclause. It is created as aNUMBERcolumn. -
The optional
PATHclause specifies that the portion of the XQuery result that is addressed by XQuery expression string is to be used as the column content. If you omitPATH, then the XQuery expressioncolumnis assumed. For example:XMLTable(... COLUMNS xyz
is equivalent to
XMLTable(... COLUMNS xyz PATH 'XYZ')
You can use different
PATHclauses to split the XQuery result into different virtual-table columns.
-
The optional
DEFAULTclause specifies the value to use when thePATHexpression results in an empty sequence. Itsexpris an XQuery expression that is evaluated to produce the default value. -
See Also:
Oracle XML DB Developer's Guide for more information on theXMLTablefunction, including additional examples, and on XQuery in general -
SELECT warehouse_name warehouse, warehouse2."Water", warehouse2."Rail" FROM warehouses, XMLTABLE('/Warehouse' PASSING warehouses.warehouse_spec COLUMNS "Water" varchar2(6) PATH '/Warehouse/WaterAccess', "Rail" varchar2(6) PATH '/Warehouse/RailAccess') warehouse2; WAREHOUSE Water Rail ----------------------------------- ------ ------ Southlake, Texas Y N San Francisco Y N New Jersey N N Seattle, Washington N Y
-
浙公网安备 33010602011771号