[英]Oracle Query to get data from more complex XML clob
我有一個相當復雜的clob塞滿了oracle中的xml,我想在SQL查詢中解析,就像我過去使用過Extract和ExtractValue一樣。
名稱類型
ATTRIBUTES CLOB
我過去使用的簡單查詢
SELECT EXTRACT(EXTRACT(xmltype.createxml(ATTRIBUTES),
'/Attributes/Map/entry[@key=""buildMapRule""]'),'/entry/@value').getStringVal() AS RULE
FROM SPT_APPLICATION
過去常常用於從XML獲取簡單數據
<Attributes>
<Map>
<entry key="afterProvisioningRule"/>
<entry key="beforeProvisioningRule"/>
<entry key="buildMapRule" value="Build Map Rule - ALM"/>
</Map>
</Attributes>
但現在我有這樣的事情
<Attributes>
<Map>
<entry key="buildMapRule" value="Build Map Rule - ALM"/>
<entry key="compositeDefinition"/>
<entry key="disableOrderingCheck">
<value>
<Boolean>true</Boolean>
</value>
</entry>
<entry key="group.mergeRows">
<value>
<Boolean></Boolean>
</value>
</entry>
<entry key="group.useExecuteQuery">
<value>
<Boolean></Boolean>
</value>
</entry>
<entry key="myColumns">
<value>
<List>
<String>Account Index</String>
<String>Account Index2</String>
<String>Account Index3</String>
</List>
</value>
</entry>
</Map>
</Attributes>
我想使用oracle風格的sql以可用的格式提取這個xml的數據.....這樣的東西,但我願意聽,如果它是另一種格式...所以基本上扁平的格式....我是認為xmlTable會幫助我,但可以通過了解所有列( XML complex Parsing )動態完成此鏈接顯然知道列和類型
entryKey entryValue subComponentName subComponentValue
查看Oracle xmltype
: http : xmltype
示例摘要:
procedure myProc( xml_in in clob ) is
myXML xmltype;
begin
myXML := xmltype.createxml( xml_in );
/*
from here you can then use functions like:
extract()
xmlsequence()
etc... look through the docs, there's plenty of functions to use,
they should satisfy your needs
*/
end;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.