你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
将XML应用程序从DB2 8.x迁移到Viper(4)
 

示例查询

下面是示例查询:

替换节点:action=replace。

通过使用复杂名称元素替换简单名称元素来更新测试文档:

Call DB2XMLFUNCTIONS.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。

Call DB2XMLFUNCTIONS.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。

Call DB2XMLFUNCTIONS.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 文档执行多个操作:

Call DB2XMLFUNCTIONS.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 中注册。

Call DB2XMLFUNCTIONS.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 替换属性值。

Call DB2XMLFUNCTIONS.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 替换文本值。

Call DB2XMLFUNCTIONS.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',?,?);

(编辑:aniston)

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089