XMLEXISTS operator
Derby Reference Manual
145
VARCHAR (DatetimeExpression )
DatetimeExpression
An expression whose value must be of a date, time, or timestamp data type.
Example
Using the EMPLOYEE table, select the job description (JOB defined as CHAR(8)) for
Dolores Quintana as a VARCHAR equivelant:
SELECT VARCHAR(JOB)
FROM EMPLOYEE
WHERE LASTNAME = 'QUINTANA'
XMLEXISTS operator
XMLEXISTS is an SQL/XML operator that you can use to query XML values in SQL.
The XMLEXISTS operator has two arguments, an XML query expression and a Derby
XML value.
Syntax
XMLEXISTS ( xquery-string-literal
PASSING BY REF xml-value-expression [ BY REF ] )
xquery-string-literal
Must be specified as a string literal. If this argument is specified as a parameter,
an expression that is not a literal, or a literal that is not a string (for example an
integer), Derby throws an error. The
xquery-string-literal
argument must
also be an XPath expression that is supported by Apache Xalan. Derby uses Apache
Xalan to evaluate all XML query expressions. Because Xalan does not support full
XQuery, neither does Derby. If Xalan is unable to compile or execute the query
argument, Derby 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:
and
.
xml-value-expression
Must be an XML data value and must constitute a well-formed SQL/XML document.
The
xml-value-expression
argument cannot be a parameter. Derby 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 the
Derby
, the argument is accepted if it is a sequence of exactly
one node that is a document node. Otherwise Derby throws an error.
BY REF
Optional keywords that describe the only value passing mechanism supported by
Derby. Since BY REF is also the default passing mechanism, the XMLEXISTS
operator behaves the same whether the keywords are present or not. For more
information on passing mechanisms, see the SQL/XML specification.
Operator results and combining with other operators
The result of the XMLEXISTS operator is a SQL boolean value that is based
on the results from evaluating the
xquery-string-literal
against the
xml-value-expression
. The XMLEXISTS operator returns:
UNKNOWN
When the
xml-value-expression
is null.
TRUE
When the evaluation of the specified query expression against the specified xml-value
returns a non-empty sequence of nodes or values.
FALSE