Xquery to update value of a node of a xml stored in a column of a table
i use DB2 express-c edition v9.1 database management system.
name of the table: student
name of the column: coursexml in the column:
<ids>
<course>
<id>
**101**
</id>
<lecture-id>
**0**
</lecture-id>
</course>
<course>
<id>
**102**
</id>
<lecture-id>
**2**
</lecture-id>
</course>
</ids>
开发者_JAVA百科I need to update the value of <lecture-id>
node of <course>
node with <id>
node as 101, to 1.
I think it can be like this:
UPDATE student
SET course = XMLQUERY('transform
copy $new := $i
modify do replace value of $new/ids/course/lecture-id
with 1
return $new' PASSING course AS "i")
WHERE id = 101;
精彩评论