Quantifiers

Another way DataDirect XQuery® minimizes data retrieval is by implementing quantified expressions with SQL in the database. These expressions are generally used in predicates and Where clauses, reducing the number of rows retrieved from the database.

Example 3. Quantifier Pushdown

XQuery

for $u in collection("USERS")/USERS
where every $h in collection("HOLDINGS")/HOLDINGS[USERID=$u/USERID]
satisfies $h/SHARES > 1000
return <user id="{$u/LASTNAME}"/>

Generated SQL

SELECT ALL
nrm5."LASTNAME" AS RACOL2
FROM
"PEPPINO"."USERS" nrm5
WHERE
NOT EXISTS(
SELECT ALL 1 AS RACOL1
FROM "PEPPINO"."HOLDINGS" nrm10
WHERE CASE WHEN nrm10."SHARES" > 1000 THEN 0 ELSE 1 END) !=0
AND nrm10."USERID" = nrm5."USERID"
AND LENGTH(nrm10."USERID") = LENGTH(nrm5."USERID")

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!

Online Video Tutorials!

Our easy-to-follow online video tutorials are a great way to get acquainted with the many features of DataDirect XQuery®.

And if you like what you see, download a free copy today and try DataDirect XQuery® for yourself!

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.