1

我有一个 XML 文档保存在一个带有 XML 数据类型的 DB2 表中,我想更新一个节点的值。我试过这个:

XQUERY replace value of node db2-fn:sqlquery('select my_xml_column from myTable where someId = someValue)/some/xpath/with/@attribute with "foobar"

(我尝试了几种变体,谷歌暗示它可以完成这项工作的所有内容)。但不幸的是,我只是收到错误消息。这里:

SQL16002N  An XQuery expression has an unexpected token "value" following "replace ". Expected tokens may include: "

我究竟做错了什么?

4

1 回答 1

1

update myTable SET myXmlColumn = XMLQUERY(' transform copy $copy := $original modify do replace value of $copy/some/xpath/with/@attribute with "FOOBAR" return $copy ' PASSING myXmlColumn AS "original" ) WHERE someId = someValue

这有效并具有预期的效果。它希望有人想出一个纯 XQuery 解决方案,但问题解决了……

于 2011-06-28T18:51:27.370 回答