Oracle xml实践
来源:互联网 发布:宝宝树 知乎 编辑:程序博客网 时间:2024/04/29 02:41
官方参考文档:XML DB Developer's Guide(11.2)
1、带有XMLType字段的表操作
-- Create tablecreate table T_XML_TEST( id NUMBER, xml_value XMLTYPE);
--使用xmltype数据类型的静态方法createxml插入xml数据INSERT INTO T_XML_TEST(id, xml_value) VALUES (1, XMLType.CreateXML( '<?xml version="1.0"?> <Envelope> <Body> <sayHelloResponse> <return>94065中国 say: hello [axis2]</return> </sayHelloResponse> </Body> </Envelope>''));
--查询带xmltype类型字段的表的方法select t.id, t.xml_value.getclobval() xml_value from T_XML_TEST t;
2、XMLTABLE函数使用,检索xml节点的值
(1)xml不带命名空间,如下xml:
<?xml version="1.0"?> <Envelope> <Body> <sayHelloResponse> <return>94065中国 say: hello [axis2]</return> </sayHelloResponse> </Body> </Envelope>
示例:
SELECT t."return", t."return2" FROM XMLTABLE(XMLNAMESPACES('http://www.w3.org/2003/05/soap-envelope' as "soap", 'http://ws.apache.org/axis2' as "tns" ) ,'/Envelope' PASSING Xmltype.createxml( '<?xml version="1.0"?> <Envelope> <Body> <sayHelloResponse> <return>94065中国 say: hello [axis2]</return> </sayHelloResponse> </Body> </Envelope>' ) COLUMNS "return" varchar2(100) PATH '/Envelope/Body/sayHelloResponse/return' ,"return2" varchar2(100) PATH '/Envelope/Body/sayHelloResponse/return' ) t;
输出结果:
(2)xml带有命名空间,如下xml:
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.apache.org/axis2"> <soap:Body> <tns:delete> <tns:record_id>7352</tns:record_id> </tns:delete> </soap:Body> </soap:Envelope>
示例:
SELECT t."return", t."return2" FROM XMLTABLE(XMLNAMESPACES('http://www.w3.org/2003/05/soap-envelope' as "soap", 'http://ws.apache.org/axis2' as "tns" ) ,'/soap:Envelope' PASSING Xmltype.createxml( '<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://ws.apache.org/axis2"> <soap:Body> <tns:delete> <tns:record_id>7352</tns:record_id> </tns:delete> </soap:Body> </soap:Envelope>' ) COLUMNS "return" varchar2(10) PATH '/soap:Envelope/soap:Body/tns:delete/tns:record_id' ,"return2" varchar2(10) PATH '/soap:Envelope/soap:Body/tns:delete/tns:record_id' ) t
输出结果:
(3)附加where条件
SELECT t.id, t.xml_value.getclobval(), t2."return" FROM T_XML_TEST t, XMLTABLE(XMLNAMESPACES('http://www.w3.org/2003/05/soap-envelope' as "soap", 'http://ws.apache.org/axis2' as "tns" ) ,'/soap:Envelope' PASSING t.xml_value COLUMNS "return" varchar2(10) PATH '/soap:Envelope/soap:Body/tns:delete/tns:record_id') t2 where t.id = 254;
- Oracle xml实践
- XML 优化项目实践
- xml的应用实践
- xml-rpc的实践
- 实践pom.xml
- XML学习及实践
- oracle xml
- oracle xml
- ORACLE 数据库实践课程
- Oracle最差实践(一)
- Oracle DDL实践记实
- oracle lead 使用实践
- oracle 字符串处理实践
- oracle lead 使用实践
- Oracle SQL最佳实践
- Oracle SQL最佳实践
- Oracle RMAN 实践
- Oracle操作实践总结
- php中session过期时间设置
- Orchard不能使用IIS部署的可能原因
- C++ 的内部连接(internal linkage)和外部连接(external linkage) 2--- 总结
- bash命令行解析getopt用法
- translateAndGetResult @ RopTranslator.java 源码分析------流水记录(一)
- Oracle xml实践
- 获取客户端IP地址 C#
- C++学习——第10章 程序文件和预处理器指令
- 硬件扫盲之---网卡
- pthread(1) 创建线程
- ioctl设备控制及例子
- WINDOWS XP英文版下Movie Maker
- java运算符
- GoogleCode SVN应用个人心得分享