我在oracle中有一个相当复杂的clob,我想在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
答案 0 :(得分:0)
了解Oracle xmltype
: http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/t_xml.htm#ARPLS369
示例摘录:
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;