[英]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. 我使用DB2 express-c版本v9.1数据库管理系统。
name of the table: student 表名:学生
name of the column: course 列名:课程
xml in the column: 列中的xml:
<ids>
<course>
<id>
**101**
</id>
<lecture-id>
**0**
</lecture-id>
</course>
<course>
<id>
**102**
</id>
<lecture-id>
**2**
</lecture-id>
</course>
</ids>
I need to update the value of <lecture-id>
node of <course>
node with <id>
node as 101 , to 1 . 我需要更新的值
<lecture-id>
的节点<course>
与节点<id>
节点101,为1。
how should I query the database to get the desired result. 我应该如何查询数据库以获得所需的结果。
any help would be highly appreciated. 任何帮助将不胜感激。
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.