Oracle extractValue返回无效令牌

时间:2019-02-15 05:33:24

标签: sql xml oracle

我有此查询,此提取值失败

EXTRACTVALUE(xmltype(REQUEST), '/soapenv:Envelope/soapenv:Body/ns2:getCustomerRequestRetrieve/ns2:requestHeader/ns5:referenceID', 'xmlns:soapenv:http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns8="ca/bell/oms/autotype/customerrequestretrieve" xmlns:ns2="ca/bell/oms/autotype/customerrequestretrieve"') RequestReferenceID

我在某个地方设置了错误的路径。你能让我知道我在哪里出错吗 实际的XML是

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns2:getCustomerRequestRetrieve xmlns = "ca/bell/oms/autotype/omscommonresponse"
            xmlns:ns5 = "sa/cell/oms/autotype/omscommonrequest"
            xmlns:ns2 = "sa/cell/oms/autotype/customerrequestretrieve"
            xmlns:ns3 = "sa/cell/oms/autotype/omscommon"
            xmlns:ns4 = "sa/cell/oms/customerprofile">
            <ns2:requestHeader>
                <ns5:customerInteractionType>CustomerNotification</ns5:customerInteractionType>
                <ns5:serviceRequestUserId>null</ns5:serviceRequestUserId>
                <ns5:serviceConsumer>khg</ns5:serviceConsumer>
                <ns5:serviceRequestTimestamp>2019-02-05T03:50:12.000-05:00</ns5:serviceRequestTimestamp>
                <ns5:language>English</ns5:language>
                <ns5:referenceID>Tjutrf7T78H4</ns5:referenceID>
                <ns5:transactionIdentifier>eed7ffe0-da22-498f-9913-c2279d1549356612606</ns5:transactionIdentifier>
            </ns2:requestHeader>
            <ns2:searchCriteria>
                <ns2:requestIdentifier>
                    <ns2:orderNumber>TTjutrf7T8H4</ns2:orderNumber>
                </ns2:requestIdentifier>
            </ns2:searchCriteria>
            <ns2:filterCriteria>
                <ns2:fullOrderDetail>ContactOnly</ns2:fullOrderDetail>
            </ns2:filterCriteria>
        </ns2:getCustomerRequestRetrieve>
    </soapenv:Body>
</soapenv:Envelope>

在此处输入代码

1 个答案:

答案 0 :(得分:0)

您在命名空间声明中存在错误。

EXTRACTVALUE(REQUEST, '/soapenv:Envelope/soapenv:Body/ns2:getCustomerRequestRetrieve/ns2:requestHeader/ns5:referenceID'
,'xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns2="sa/cell/oms/autotype/customerrequestretrieve"
xmlns:ns5="sa/cell/oms/autotype/omscommonrequest"
') RequestReferenceID

此外,不建议使用EXTRACTVALUE函数。 Replacemnet是xmlquery,xmltable。

select xmlcast(xmlquery('declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/";
declare namespace ns2="sa/cell/oms/autotype/customerrequestretrieve";
declare namespace ns5="sa/cell/oms/autotype/omscommonrequest";
/soapenv:Envelope/soapenv:Body/ns2:getCustomerRequestRetrieve/ns2:requestHeader/ns5:referenceID/text()' passing xmltype(request) returning content) as varchar2(100)) from ....;