XML QUERY LANGUAGES: XQUERY AND XPATH Chocolate Ice Cream 1.50 ) into /Invoice[1]/LineItems[1] ) The afterand beforekeywords are used to insert siblings at the same level of hierarchy in the document. These keywords cannot be used in the same statement as into; this produces an error. It is also an error to use the afterand beforekeywords when inserting attributes. Following our earlier example, if you want to set the InvoiceDate at a specific position in the Invoice element s set of children, you need to use the before or after keywords and have an XPath expression that points to the appropriate sibling. SET @x.modify( insert 2002-06-15 before /Invoice[1]/CustomerName[1] ) this works too, and equates to the same position SET @x.modify( insert 2002-06-15 after /Invoice[1]/InvoiceID[1] ) The key to understanding the insert statement is that although Expression1can be any of the seven node types and can contain multiple nodes in a sequence or even hierarchical XML, Expression2 must evaluate to a single node. If Expression2 evaluates to a sequence of nodes and no node, the insert statement will fail. In addition, Expression2 cannot refer to a node that has been constructed earlier in the query; it must refer to a node in the original XML instance. This is what the variable looks like after all the previous modifications. Although InvoiceDate was used multiple times in multiple examples, we ve chosen to show only the insert position from the last example (ignoring the first two examples, where InvoiceDatewas inserted in a different position). value in the variable @x after modifications 1000 2002-06-15 Jane Smith 134 10 Chicken Patties 9.95

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Adult Web Hosting services

Bookmark the permalink.

Comments are closed.