将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=? &yuml;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:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-07-05  
  12345
6789101112
13141516171819
20212223242526
2728293031  

数据统计

  • 访问量: 55049
  • 日志数: 24223
  • 建立时间: 2007-12-06
  • 更新时间: 2008-06-15

RSS订阅

Open Toolbar