使用oracle plsql提取XML clob

时间:2016-09-15 10:46:47

标签: xml oracle xml-parsing

我有一个如下的xml,想要提取它并将其保存在行和列中

<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>
                </Operands>
            </Operand>
        </Operands>
    </Condition>
</QualificationCriterion>

尝试将结果作为

QualificationCriterion_name    Attribute_name      name             Experssion_type1    Expression_type2

iPass Roaming Zone 1        Service filter     Last BLIMPACT Cycle Month        AND         AND
iPass Roaming Zone 1        Provider ID     23102               OR              AND

我尝试使用以下代码,

SELECT x.id,
       x.xmltype(element_value).EXTRACT('//QualificationCriterion/@name') QC_NAME,
       x.xmltype(element_value).EXTRACT('//QualificationCriterion/Condition/@expressionType') Outer_gate,
       x.xmltype(element_value).EXTRACT('//QualificationCriterion/Condition/Operands/Operand/@expressionType') inner_gate,
       x.xmltype(element_value).EXTRACT('//QualificationCriterion/Condition/Operands/Operand/Operands/Operand/LeftOperand/@attributeName') value4,
       x.xmltype(element_value).EXTRACT('//QualificationCriterion/Condition/Operands/Operand/Operands/Operand/RightOperand/@Value') value5
  FROM (SELECT *
          FROM pc_element
         WHERE     element_type = 'QualificationCriterion'
               AND name = 'iPass Roaming Zone 1'
               AND id = '184413403') x,
       TABLE(XMLSEQUENCE(EXTRACT(xmltype(element_value), '/QualificationCriterion/Condition/Operands/Operand/Operands/Operand/LeftOperand'))) p;

但是value5变为null并且XMLsequence也没有按预期工作,它只给了我15行中相同的值

0 个答案:

没有答案