XQuery Global Variables

SQL does not have a construct equivalent to XQuery's global variables. When an XQuery global variable is set to values from the database, DataDirect XQuery® generally inlines the variable in the statement created for the query body.

Example 12. Global Variables

XQuery

declare variable $users := collection('USERS')/USERS;
for $u in $users
return $u/LASTNAME

Generated SQL

SELECT ALL
nrm5."LASTNAME" AS RACOL1
FROM
"PEPPINO"."USERS" nrm5
WHERE
nrm5."LASTNAME" IS NOT NULL

Try DataDirect XQuery® Free!

Put the power, scalability, and performance of DataDirect XQuery® to work for you today! Our free trial lets you see for yourself how easy it is to build data integration applications that access relational, EDI, and other file formats as XML!

Download DataDirect XQuery® today!

Stay Informed!

XQuery is one of the hottest XML technologies being developed today. Stay informed with vital news about standards, tools, and trends by signing up for the DataDirect XQuery® newsletter.