簡體   English   中英

使用Oracle中的CLOB列提取來查詢xml

[英]Query xml using extract over CLOB column in Oracle

我們將xml存儲在oracle數據庫中。 列類型為CLOB。 我可以使用下面的查詢從xml標記中獲取數據。 當我執行查詢時,我得到空值。

列中的XML:

<input xmlns="http://google.com/testsystem" 
       xmlns:testsystem="http://test.com/testSystem"          
       xmlns:tns="http://google.com/testService/">
      <ProcessData>      
        <reviewYear>2014-2015</reviewYear>
      </ProcessData>
    </input>

表名:test_table
列名:input_xml
列類型:CLOB

查詢:

select extract(xmltype(input_xml),'//reviewYear/text()').getStringVal() as data 
from test_table 
where id = 1;

結果:

DATA                  
------------------------------------

您需要指定名稱空間,請嘗試下一個查詢

select extract(xmltype('<input xmlns="http://google.com/testsystem" 
       xmlns:testsystem="http://test.com/testSystem"          
       xmlns:tns="http://google.com/testService/">
      <ProcessData>      
        <reviewYear>2014-2015</reviewYear>
      </ProcessData>
    </input>'),'/input/ProcessData/reviewYear/text()', 'xmlns="http://google.com/testsystem" xmlns:testsystem="http://test.com/testSystem" xmlns:tns="http://google.com/testService/"').getStringVal() as data 
from dual

UPD。

進行更新嘗試

select updatexml(xmltype('<input xmlns="http://google.com/testsystem" 
       xmlns:testsystem="http://test.com/testSystem"          
       xmlns:tns="http://google.com/testService/">
       <ProcessData>      
         <reviewYear>2014-2015</reviewYear>
       </ProcessData>
    </input>'), '/input/ProcessData/reviewYear/text()', '2013-2014', 
    'xmlns="http://google.com/testsystem" xmlns:testsystem="http://test.com/testSystem" xmlns:tns="http://google.com/testService/"').getclobval() as data 
from dual

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM