【问题标题】:Oracle Query to get data from more complex XML clobOracle Query 从更复杂的 XML Clob 中获取数据
【发布时间】:2013-11-08 20:05:58
【问题描述】:

我有一个相当复杂的 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 complex Parsing)的情况下动态完成这个链接显然知道列和类型

entryKey     entryValue     subComponentName     subComponentValue

【问题讨论】:

  • 我很乐意为您提供帮助,并且可能有能力这样做,但在阅读多次后我不明白这个问题。你能改写一下吗?
  • 我质疑列名是在哪里确定的?在其他一些软件里面?有什么方法可以知道需要哪些列?

标签: sql xml oracle parsing extract


【解决方案1】:

查看 Oracle xmltypehttp://docs.oracle.com/cd/E11882_01/appdev.112/e25788/t_xml.htm#ARPLS369

示例 sn-ps:

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 extract values from xmltype

【讨论】:

    猜你喜欢
    • 2022-07-21
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    • 2011-06-20
    • 2018-02-23
    • 2015-09-08
    • 1970-01-01
    相关资源
    最近更新 更多