In DB2® V10.1, the DB2 server has been optimized to improve performance for certain commonly used queries, such as those that use the XMLTABLE function.
SELECT T.* FROM TEST,
XMLTABLE('$doc/a/b' passing TEST.XMLCOL as "doc" columns
c varchar(10) path 'c1/c2/c'
d varchar(10) path 'd1/d2/d'
e varchar(10) path 'e1/e2/e') AS T;
xquery for $a in db2-fn:xmlcolumn('XTAB.DOC')/a
for $b in $a/b
for $c in $a/c
return <res>{$b,$c}</res>
SELECT stat, gen FROM custacc,
XMLTABLE('$CADOC/Customer [DateOfBirth >= xs:date("1910-01-01")
and BankingInfo/PremiumCustomer = "No"] '
COLUMNS
GEN VARCHAR(20) PATH 'Gender',
Nationality VARCHAR(20) PATH 'Customer/Nationality,
STAT VARCHAR(20) PATH 'BankingInfo/CustomerStatus');
xquery for $i in db2-fn:xmlcolumn('T.XMLCOL')/PRODUCT,
$j in $i[NAME='5Z761']//PRICE
return $j
SELECT T.* FROM TEST,
XMLTABLE ( '$doc/a/b' passing TEST.XMLCOL as "doc" columns
c varchar(10) path 'c1/c2/c'
d varchar(10) path '../d1/d2/d'
e varchar(10) path '../../e1/e2/e') as T
xquery let $doc := db2-fn:xmlcolumn('T.XMLCOL') return ($doc/root//a/.. )/b