Update multiple nodes in a row in a single query
523496Sep 5 2006 — edited Sep 5 2006Hi
I use updateXML to change the value of a node in each row
of an XML table (structured storage). For example, if I
have the three following documents in the table:
<doc>
<elem>1</elem>
</doc>
<doc>
<elem>2</elem>
</doc>
<doc>
<elem>1</elem>
</doc>
I can change the @val value to "3" where it is equal to
"1" by using:
UPDATE my_table
SET OBJECT_VALUE = updateXML(OBJECT_VALUE, '/doc/elem/text()', '3')
WHERE existsNode(OBJECT_VALUE, '/doc/elem/text() = "1"') = 1;
But how to achieve the same goal when there are several
nodes to update in a row, as updateXML can only update a
single node? For example, how to make the same update as
the example above, but with the following documents in the
table:
<doc>
<elem>1</elem>
</doc>
<doc>
<elem>2</elem>
</doc>
<doc>
<elem>1</elem>
<elem>1</elem>
</doc>
Thanks in advance.
Regards,
--drkm