Team Fly |
update xcustomer c set value(c) = updateXML(value(c), '/customer/name/text()','Pat Jones') /
CAUTION
The previous statement will update all XML documents stored within the XCUSTOMER table. To avoid this global update, we must constrain our SQL query to select only the XML document we want. To define the constraint, we will need to identify the node within the XML document we want and return its value, a problem that will be addressed in the next section.
NOTE
updatexml() can be used to update, replace elements, attributes, and other nodes with new values. This function cannot be directly used to insert new nodes or delete existing ones.
As we have just defined, XML Type tables and columns are able to store XML data within them. Let's continue on to see how we can retrieve the data.
The first thing you might do as a relational developer after finding out that XML data can be loaded into an Oracle Database 10g is some querying. Is querying different with this XML data? Are the queries ordinary SQL? Because Oracle XML DB is fundamentally based on the Oracle Database 10g relational architecture, the familiar SQL paradigm continues to work well in this new world.
The first thing to realize is that, to query documents in Oracle XML DB, you use SQL with some functional extensions. Here are a handful of SQL functions that use XPath notations and are part of a set of extensions to SQL that Oracle has implemented in Oracle Database 10g:
The existsnode() function is used in the where clause of a SQL query to restrict the set of documents to be returned. The existsnode() function applies an XPath expression to an XML document and returns true (1) or false (0) depending on whether or not the document contains a node which matches the XPath expression.
Team Fly |