简体   繁体   English

Oracle SQL - 使用重复节点从XML中提取clob值

[英]Oracle SQL - Extracting clob value from XML with repeating nodes

I am attempting to run SQL on a table (called test_xml with a column xml_data [data type xmltype]). 我试图在一个表上运行SQL(名为test_xmlxml_data [数据类型xmltype])。 The column contains xml with repeating nodes ( test_3 ). 该列包含具有重复节点的xml( test_3 )。 The following statement runs successfully when the node contains data of a non clob size: 当节点包含非clob大小的数据时,以下语句成功运行:

SELECT 
   extractvalue (Value (wl), '*/test_3')
      FROM test_xml
         , TABLE (xmlsequence (extract (xml_data, '*/record'))) wl

but fails when test_3 node contains a lot of data: 但是当test_3节点包含大量数据时失败:

ORA-01706: user function result value was too large ORA-01706:用户功能结果值太大

I amended my query: 我修改了我的查询:

SELECT 
   extractvalue(Value (wl), '*/test_3').getClobVal()
      FROM test_xml
         , TABLE (xmlsequence (extract (xml_data, '*/record'))) wl

but this fails with: 但这失败了:

ORA-22806: not an object or REF ORA-22806:不是对象或REF

This was resolved via a response received on Oracle Forums: 通过Oracle论坛收到的回复解决了这个问题:

See Forum Post 见论坛帖子

From Oracle release 11.2.0.2: 从Oracle 11.2.0.2版开始:

SELECT x.*
FROM test_xml t
   , XMLTable(
       '/*/record'
       passing t.xml_data
       columns
         test_3  clob path 'test_3'
     ) x
;

My database version is 10.2.0.4 hence the following 'trick' is required: 我的数据库版本是10.2.0.4,因此需要以下“技巧”:

SELECT dbms_xmlgen.convert(x.test_3.getClobVal(), 1) as test_3
FROM test_xml t
   , XMLTable(
       '/*/record'
       passing t.xml_data
       columns
         test_3  xmltype path 'test_3/text()'
     ) x
;

Thanks go to odie_63 for this 谢谢你去odie_63吧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM