4

我有一个相当复杂的 clob,在 oracle 中填充了 xml,我想在 SQL 查询中解析它,就像我过去使用 Extract 和 ExtractValue 一样。

名称 类型
属性 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 复杂解析)的情况下动态完成此链接显然知道列和类型

entryKey entryValue subComponentName subComponentValue

4

1 回答 1

0

查看甲骨文xmltypehttp ://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;

https://community.oracle.com/thread/2378521?tstart=0

Oracle 从 xmltype 中提取值

于 2014-02-12T19:05:07.153 回答