•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 455,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 4617 | Replies: 32
![]() |
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
DB2 treats XQuery as a first-class language, allowing users to write Xquery expressions directly rather than requiring that users embed or wrap XQueries in SQL statements. DB2's query engine processes XQueries natively, meaning that it parses, evaluates, and optimizes XQueries without ever translating them into SQL behind the scenes. You can check http://www.ibm.com/developerworks/db...-0603saracco2/ to know how to use several popular SQL/XML expressions to query DB2 XML data XQuery.
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
Yes, you can write "bilingual" queries that include both XQuery and SQL expressions. DB2 will process and optimize these queries as well. To embed SQL in an XQuery, you use the db2-fn:sqlquery function in place of the db2-fn:xmlcolumn function. The db2 fn:sqlquery function executes an SQL query and returns only the selected data. The SQL query passed to db2-fn:sqlquery must only return XML data; this enables XQuery to further process the result of the SQL query. Please check http://www.ibm.com/developerworks/db...dm-0606nicola/ to know when to use SQL/XML or Xquery to query the XML data.
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
To execute an XQuery directly in DB2, you must preface the query with the keyword XQuery. This instructs DB2 to invoke its XQuery parser to process your request. You only need to do this if you are using XQuery as the outermost (or top level) language. If you embed XQuery expressions in SQL, you don't need to preface them with the XQuery keyword.
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
yes, you can also embed XQueries in SQL. Indeed, DB2 9 features support for standard SQL/XML functions that are frequently used to formulate hybrid queries in which SQL is the outermost (or top-level) language. You can use XMLExists function for this. This function lets you navigate to an element (or other type of node) within your XML document and test for a specific condition. When specified as part of the SQL
WHERE clause, XMLExists restricts the returned results to only those rows that contain an XML document that satisfies your specified condition (where the specified condition evaluates to "true").
![]() |
•
•
•
•
•
•
•
•
DaniWeb XML, XSLT and XPATH Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- XML Management (RSS, Web Services and SOAP)
- Database Design : DB2 + PHP + Windows? (Database Design)
- Unable to uninstall DB2 Express-c (Win XP Home) (Windows NT / 2000 / XP / 2003)
- Complete guideline book for the DB2 (Shell Scripting)
- shell script manual for db2 (Shell Scripting)
- extracting db2 table records to csv (Shell Scripting)
- Simple question about using JDBC to access DB2 (Java)
- Immediate project for IBM DB2 UDB database administrator (Software Development Job Offers)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Xpath
- Next Thread: SQL/XML Query


Linear Mode