首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用XMLtable/Xpath转换XML Clob并将其存储在数据库表中

使用XMLtable/Xpath转换XML Clob并将其存储在数据库表中
EN

Stack Overflow用户
提问于 2016-09-27 09:09:59
回答 1查看 1.4K关注 0票数 0

我正在尝试使用Oracle /SQL将XMl解压缩到行和列中,但不以所需的格式获取

XML:-

代码语言:javascript
运行
复制
<QualificationCriterion name="iPass Roaming Zone 1" description="" id="##PC4.0##183647208" status="CheckedIn" kind="Implementation" eventName="##PC4.0##67625472">
    <Condition xsi:type="LogicalExpression" expressionType="AND" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Operands>
            <Operand xsi:type="LogicalExpression" expressionType="AND">
                <Operands>
                    <Operand xsi:type="Comparison" expressionType="NE" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6249415" entity="Event" entityName="##PC4.0##67625472" attributeName="Service filter"/>
                        <RightOperand xsi:type="ValueRef" type="##PC4.0##6249415" name="Pseudo Allowance "/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##76915825" entity="Customer" entityName="##PC4.0##701" attributeName="Last BLIMPACT Cycle Month"/>
                        <RightOperand xsi:type="ValueRef" type="##PC4.0##76915825" name="Wholesale"/>
                    </Operand>
                </Operands>
            </Operand>
            <Operand xsi:type="LogicalExpression" expressionType="OR">
                <Operands>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="23102"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="21630"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="26201"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="23001"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="23203"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="20420"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##8537479" value="23207"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##6250817" value="21901"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##6250817" value="20416"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6250817" entity="Event" entityName="##PC4.0##67625472" attributeName="Provider ID"/>
                        <RightOperand xsi:type="Constant" type="##PC4.0##6250817" value="22004"/>
                    </Operand>
                </Operands>
            </Operand>
            <Operand xsi:type="LogicalExpression" expressionType="OR">
                <Operands>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6249415" entity="Event" entityName="##PC4.0##67625472" attributeName="Service filter"/>
                        <RightOperand xsi:type="ValueRef" type="##PC4.0##6249415" name="ROAMBL"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6249415" entity="Event" entityName="##PC4.0##67625472" attributeName="Service filter"/>
                        <RightOperand xsi:type="ValueRef" type="##PC4.0##6249415" name="ROAMGP"/>
                    </Operand>
                    <Operand xsi:type="Comparison" expressionType="EQ" type="Boolean">
                        <LeftOperand xsi:type="AttributeRef" type="##PC4.0##6249415" entity="Event" entityName="##PC4.0##67625472" attributeName="Service filter"/>
                        <RightOperand xsi:type="ValueRef" type="##PC4.0##6249415" name="GPRSRM"/>
                    </Operand>
                </Operands>
            </Operand>
        </Operands>
    </Condition>
</QualificationCriterion>

预期OutPut :-

名称: value1 value2 value4 iPass漫游区1服务过滤器伪容量和iPass漫游区域1最后一个BLIMPACT循环月批发和iPass漫游区1 iPass漫游区1提供者ID 23102或iPass漫游区1提供者ID 21630或iPass漫游区1提供者ID 26201或iPass漫游区1提供者ID 23001或iPass漫游区域1 提供者ID 23203或iPass漫游区1提供者ID 20420或iPass漫游区1提供者ID 23207或iPass漫游区1 提供者ID 21901或iPass漫游区1提供者ID 20416或iPass漫游区1提供者ID 22004或iPass漫游区1 iPass漫游区1服务过滤器ROAMBL或iPass漫游区1服务过滤器ROAMGP或iPass漫游区1服务过滤器GPRSRM或

到现在为止我所拥有的,

value1 value2 value3 value4 iPass漫游区1 和iPass漫游区1服务过滤器iPass漫游区1伪津贴iPass漫游区1最后一个BLIMPACT循环月iPass漫游区1批发iPass漫游区1或iPass漫游区1 提供商ID iPass漫游区1 23102 iPass漫游区1提供者ID iPass漫游区域1 21630 iPass漫游区1提供者ID iPass漫游区1 26201 iPass漫游区1提供程序ID iPass漫游区1 23001 iPass漫游区1 提供商ID iPass漫游区1 23203 iPass漫游区1提供者ID iPass漫游区域1 20420 iPass漫游区1提供者ID iPass漫游区1 23207 iPass漫游区1提供程序ID iPass漫游区1 21901 iPass漫游区1 提供商ID iPass漫游区1 20416 iPass漫游区1提供者ID iPass漫游区域1 22004 iPass漫游区1或iPass漫游区1 服务过滤器iPass漫游区1 ROAMBL iPass漫游区1业务过滤器iPass漫游区1 ROAMGP iPass漫游区1服务过滤器iPass漫游区1

我的守则:-

代码语言:javascript
运行
复制
SELECT xt.*
FROM   (select * from pc_element where element_type='QualificationCriterion' and name='ETDR Group' and first_effective_version is not null and last_effective_version is null) x,
       XMLTABLE('/QualificationCriterion/Condition | //Operand[not(@type="Boolean")] | //Operands/Operand/LeftOperand | //Operands/Operand/RightOperand'
         PASSING x.xmltype(element_value)
         COLUMNS
        -- "value0"    VARCHAR2(50) PATH '@expressionType',
           "value1"    VARCHAR2(50) PATH '@attributeName',
           "value2" varchar2(10) PATH '@name',
            "value3" varchar2(10) PATH '@value',
            "value4"    VARCHAR2(50) PATH '@expressionType'
         ) xt ; 

每提取一次值,我都会得到3个空格,该值一行请帮助,我是XML解析方面的新手,非常困惑,请帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-10-02 19:41:18

下面是您需要的查询:

代码语言:javascript
运行
复制
SELECT xt.NAME NAME, xt.attributeName value1, nvl(RName,RValue) value2, xt.expressionType value4
FROM   (select * from pc_element where element_type='QualificationCriterion' and name='ETDR Group' and first_effective_version is not null and last_effective_version is null) x,
   --XMLTABLE('/QualificationCriterion/Condition | //Operands/Operand[not(@type="Boolean")] | //Operands/Operand/LeftOperand | //Operands/Operand/RightOperand'
   XMLTABLE('//Operand[@type="Boolean"]' 
     PASSING x.xmltype(element_value)
     COLUMNS
       NAME   VARCHAR2(50) PATH './../../../../../@name',
       attributeName    VARCHAR2(50) PATH './LeftOperand/@attributeName',
       RName varchar2(50) PATH './RightOperand/@name',
        RValue varchar2(50) PATH './RightOperand/@value',
        expressionType    VARCHAR2(50) PATH './../../@expressionType'
        --"self"    varchar2(50) path 'name()'
     ) xt ; 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39720616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档