Updating db via xml

A database schema can be written in XML pretty trivially.

updating db via xml-63updating db via xml-15updating db via xml-72

element SELECT x.query(' /Root/Product Description') FROM T -- update the Product Name attribute value UPDATE T SET x.modify(' replace value of (/Root/Product Description/@Product Name)[1] with "New Road Bike" ') -- verify the update SELECT x.query(' /Root/Product Description') FROM T This example replaces values in a manufacturing instructions document stored in a typed XML column.

In the example, you first create a table (T) with a typed XML column in the Adventure Works database.

If the value is a list of values, the update statement replaces the old value with the list.

In modifying a typed XML instance, must be an expression that can be atomized. The following examples of the replace value of XML DML statement illustrates how to update nodes in an XML document.

'; SELECT @my Doc; -- update text in the first manufacturing step SET @my Doc.modify(' replace value of (/Root/Location/step[1]/text())[1] with "new text describing the manu step" '); SELECT @my Doc; -- update attribute value SET @my Doc.modify(' replace value of (/Root/Location/@Labor Hours)[1] with "100.0" '); SELECT @my Doc; Note that the target being updated must be, at most, one node that is explicitly specified in the path expression by adding a "[1]" at the end of the expression.

You can specify the if expression in Expression2 of the replace value of XML DML statement, as shown in the following example. The WHERE clause specifies which record(s) that should be updated.The notion of transfering data relational databases via XML is growing in popularity. When you sign in to comment, IBM will provide your email, first name and last name to DISQUS.That information, along with your comments, will be governed by DISQUS’ privacy policy.In this paper, I attempt to outline a database schema and serialization that provides sufficient information for a the recipient of the data to store it in a relational database without losing synch with the presenter of the data.

Tags: , ,