将XML应用程序从DB2 8.x迁移到Viper(4)
上一篇 /
下一篇 2008-04-24 21:15:36
/ 个人分类:技术文章
示例查询
下面是示例查询:
替换节点:action=replace。
通过使用复杂名称元素替换简单名称元素来更新测试文档:
CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update action="replace" col="1" path="/x:customerinfo/x:name"> <name><fname>Hardeep</fname><lname>Singh</lname></name> </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? where cid=1006',?,?);
|
使用 SQL 查询获取新值以进行更新:
using=SQL。 CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update using="sql" action="replace" col="1" path="//x:customerinfo[@Cid=1006]/x:addr/x:pcode-zip/text()"> select cid from XMLCustomer where cid=1006 </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? where cid=1006',?,?);
|
使用给定表达式来计算值:
action=compute。 CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update action="compute" col="1" path="/x:customerinfo/x:addr/x:pcode-zip/text()"> (20+?)*32-? </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? ÿhere cid=1006',?,?);
|
对目标 XML 文档执行多个操作:
CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update using="sql" action="replace" col="1" path="/x:customerinfo/x:addr/x:pcode-zip/text()"> select cid from XMLCustomer where cid=1006 </update> <update action="compute" col="1" path="/x:customerinfo/x:addr/x:pcode-zip/text()"> (2+?)*10-? </update> <update action="delete" col="1" path="/x:customerinfo/x:name"/> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? where cid=1006',?,?);
|
更新文档时对其进行验证。
为此,您需要创建模式并在 XSR 中注册。
CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update using="sql" action="replace" col="1" path="/x:customerinfo/x:addr/x:pcode-zip/text()"> select cid from XMLCustomer where cid=1006 </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=xmlvalidate( ? according to XMLSCHEMA ID test.schema2) where cid=1006',?,?)
|
使用 XMLUpdate 替换属性值。
CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update action="replace" col="1" path="/x:customerinfo/x:phone/@type"> tie line </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? where cid=1006',?,?);
|
使用 XMLUpdate 替换文本值。
CallDB2XMLFUNCTIONS.XMLUPDATE ( '<updates namespaces="x:http://posample.org"> <update action="replace" col="1" path="/x:customerinfo/x:addr/x:city/text()"> San Jose </update> </updates>', 'Select info from XMLCustomer where cid=1006', 'update XMLCustomer set info=? where cid=1006',?,?);
|
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: