XMLEXISTS predicate
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The XMLEXISTS
predicate can be used to check whether an XQuery or XPath expression produces a value within an XML document (see also the XMLQUERY function)
SELECT 1 WHERE xmlexists('/a/b' PASSING '<a><b/></a>')
create.selectOne() .where(xmlexists("/a/b").passing(XML.valueOf("<a><b/></a>"))) .fetch();
Dialect support
This example using jOOQ:
xmlexists("/a/b").passing(xml("<a><b/></a>"))
Translates to the following dialect specific expressions:
DB2
XMLEXISTS( '/a/b' PASSING xmlparse(DOCUMENT '<a><b/></a>') )
Oracle
XMLEXISTS( '/a/b' PASSING xmltype.createxml('<a><b/></a>') )
Postgres
XMLEXISTS( '/a/b' PASSING CAST('<a><b/></a>' AS xml) )
SQLServer
(CAST('<a><b/></a>' AS xml).EXIST('/a/b') = 1)
Teradata
XMLEXISTS( '/a/b' PASSING '<a><b/></a>' )
ASE, Access, Aurora MySQL, Aurora Postgres, BigQuery, ClickHouse, CockroachDB, Databricks, DuckDB, Exasol, Firebird, H2, HSQLDB, Hana, Informix, MariaDB, MemSQL, MySQL, Redshift, SQLDataWarehouse, SQLite, Snowflake, Spanner, Sybase, Trino, Vertica, YugabyteDB
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!