1.0

Table Of Contents
integer),SQLFire throws an error. The xquery-string-literal argument
must also be an XPath expression that is supported by Apache Xalan. SQLFire
uses Apache Xalan to evaluate all XML query expressions. Because Xalan does
not support full XQuery, neither does SQLFire. If Xalan is unable to compile
or execute the query argument, SQLFire catches the error that is thrown by
Xalan and throws the error as a SQLException. For more on XPath and XQuery
expressions, see these Web sites: http://www.w3.org/TR/xpath and
http://www.w3.org/TR/xquery/.
Must be an XML data value and must constitute a well-formed SQL/XML
document. The xml-value-expression argument cannot be a parameter.
xml-value-expression
SQLFire does not perform implicit parsing nor casting of XML values, so use
of strings or any other data type results in an error. If the argument is a sequence
that is returned by a SQLFire XMLQUERY operation, the argument is accepted
if it is a sequence of exactly one node that is a document node. Otherwise
SQLFire throws an error.
Optional keywords that describe the only value passing mechanism supported
by SQLFire. Since BY REF is also the default passing mechanism, the
BY REF
XMLQUERY operator behaves the same whether the keywords are present or
not. For more information on passing mechanisms, see the SQL/XML
specication.
Optional keywords that describe the only XML type returned by the SQLFire
XMLQUERY operator. Since SEQUENCE is also the default return type, the
RETURNING SEQUENCE
XMLQUERY operator behaves the same whether the keywords are present or
not. For more information on the different XML return types, see the SQL/XML
specication.
Required keywords that describe the way in which XMLQUERY handles an
empty result sequence. The XMLQUERY operator returns an empty sequence
EMPTY ON EMPTY
exactly as the sequence is. The XMLQUERY operator does not convert the
empty sequence to a null value. When an empty result sequence is serialized,
the result is an empty string. SQLFire does not consider an empty result
sequence to be a well-formed XML document.
The result of the XMLQUERY operator is a value of type XML. The result represents a sequence of XML nodes
or values. Atomic values, such as strings, can be part of the result sequence. The result of an XMLQUERY
operator is not guaranteed to represent a well-formed XML document and it might not be possible to insert the
result of an XMLQUERY operator into an XML column. To store the result in an XML column, the result must
be a sequence with exactly one item in the sequence and the item must be a well-formed document node. The
result can be viewed only in serialized form by explicitly using the XMLSERIALIZE operator on page 548.
Examples
In the x_table table, to search the XML column xcol and return the students that have an age attribute that
is greater than 20, use the following statement:
SELECT ID,
XMLSERIALIZE(
XMLQUERY('//student[@age>20]' PASSING BY REF xcol EMPTY ON EMPTY)
AS VARCHAR(50))
FROM x_table
The result set for this query contains a row for every row in x_table, regardless of whether or not the
XMLQUERY operator actually returns results.
547
SQL Language Reference