The function returns the output produced by an XML view as it was a content of some XML document accessed via document() XPath function. The result of the function call may be used as input of some path expression that select interesting parts of the full output of the XML view. The XQuery engine will translate the XPath expression into SQL statement in order to avoid redundant data access and to build whole XML tree.
This function may be used only in the header of FOR operator of XQuery. To specify the list of values of a variable, a path expression may be used that starts with the call of xmlview() function.
SQLState | Error Code | Error Text | Description |
---|---|---|---|
37000 | Unknown view name is passed as argument of xmlview() |
The XQUERY expressions below are queries to the following XML view:
create xml view "cat" as { "Demo"."demo"."Categories" c as "category" ("CategoryID", "Description" as "description") { "Demo"."demo"."Products" p as "product" ("ProductName") on (p."CategoryID" = c."CategoryID") } };
The first query returns all products with the attribute ProductName starting with "L". The second query returns categories with attribute CategoryID less than 10.
for $r in xmlview("cat")//product[@ProductName like "L%"] return $r for $r in xmlview("cat")/category[@CategoryID<"10"] return $r