0

我必须得到 2 个字符串之间的值。SUBSCRIPTION_ID应该总是返回一个数字。ORDER_TYPE返回字母,特殊字符。ORDER_NUMBER总是返回一个数字。我正面临获得正确的问题ORDER_TYPE。我不知道为什么,但是 2 个字符串之间的一些值ORDER_TYPE显示为 null,这不是 null。问题只是因为 .+ , \d 这是错误的,我试图从中追加。这是我的完整我试图从中提取 2 个字符串之间的值的 xml 字符串:

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:placeShopOrderResponse xmlns:ns="http://service.soap.CDRator.com"><ns:return xmlns:ax2133="http://signup.data.soap.CDRator.com/xsd" xmlns:ax2134="http://core.signup.data.soap.CDRator.com/xsd" xmlns:ax2127="http://data.soap.CDRator.com/xsd" xmlns:ax2129="http://webshop.data.soap.CDRator.com/xsd" xmlns:ax2130="http://core.data.soap.CDRator.com/xsd" xmlns:ax2140="http://core.result.service.soap.CDRator.com/xsd" xmlns:ax2139="http://result.service.soap.CDRator.com/xsd" xmlns:ax2147="http://webshop.result.service.soap.CDRator.com/xsd" xmlns:ax2148="http://mandate.result.service.soap.CDRator.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax2147:PlaceShopOrderResultDTO"><ax2130:id xsi:nil="true" /><ax2140:code>0</ax2140:code><ax2130:description></ax2130:description><ax2130:stat>No Active BDM</ax2130:stat></ax2127:bdmStatus><ax2127:warningLogContent></ax2127:warningLogContent></ax2127:subscriptionCondition><ax2127:teleService xsi:type="ax2127:TeleServiceDTO"><ax2130:id>201501070917439768</ax2130:id><ax2130:code>TELE</ax2130:code><ax2127:serviceStatus xsi:type="ax2127:StatusDTO"><ax2130:id>100</ax2130:id><ax2130:description>Neu</ax2130:description><ax2130:stat>New</ax2130:stat></ax2127:serviceStatus><ax2130:imsi xsi:nil="true" /><ax2130:phoneNumber>NO_NUMBER</ax2130:phoneNumber><ax2127:imei xsi:nil="true" /><ax2127:simCard xsi:nil="true" /></ax2127:teleService></ax2147:subscriptions></ns:return></ns:placeShopOrderResponse></soapenv:Body></soapenv:Envelope>

这是我正在尝试的:

SELECT TEMP_SOAP_MONITORING."ID", TO_NUMBER(REPLACE(REPLACE(REGEXP_SUBSTR(RESPONSE_XML,'<ax2147:subscriptions xsi:type="ax2127:SubscriptionDTO"><ax2130:id>\d+</ax2130:id>'),
'<ax2147:subscriptions xsi:type="ax2127:SubscriptionDTO"><ax2130:id>',''),'</ax2130:id>','')) 
   AS SUBSCRIPTION_ID , 
   CAST(REPLACE(REPLACE(
  REGEXP_SUBSTR(REQUEST_XML,'<ns7:orderType>.+</ns7:orderType>'),'<ns7:orderType>',''),'</ns7:orderType>','')
  AS VARCHAR(100)) AS ORDER_TYPE,
  TO_NUMBER(REPLACE(REPLACE(REGEXP_SUBSTR(RESPONSE_XML,'<ax2147:orderNumber>\d+</ax2147:orderNumber>'),'<ax2147:orderNumber>',''),'</ax2147:orderNumber>','')) 
   AS ORDER_NUMBER 
   FROM
   TEMP_SOAP_MONITORING;
4

1 回答 1

0

我现在得到了工作查询。请检查这个,以便它可以帮助其他人。

INSERT INTO TMP_SOAP_MONITORING_IDS ("ID",SUBSCRIPTION_ID,ORDER_TYPE,ORDER_NUMBER) 
SELECT ID,xt_req.SUBSCRIPTION_ID,xt_res.ORDER_TYPE,xt_rrr.ORDER_NUMBER
FROM TEMP_SOAP_MONITORING sm
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://schemas.xmlsoap.org/soap/envelope/' AS "soapenv",
      'http://service.soap.CDRator.com' as "ns",
      'http://core.data.soap.CDRator.com/xsd' as "ax2130",
      'http://webshop.result.service.soap.CDRator.com/xsd' as "ax2147"
    ),
    'for $i in /soapenv:Envelope/soapenv:Body/ns:placeShopOrderResponse/ns:return/ax2147:subscriptions
      return $i/ax2130:id'
    passing XMLType(sm.RESPONSE_XML)
    columns "SUBSCRIPTION_ID" number path '/') xt_req
CROSS JOIN XMLTable(XMLNAMESPACES (
       'http://webshop.data.soap.CDRator.com/xsd' as "ns7"
    ),
    'for $i in //ns7:orderType return $i'
    passing XMLType(sm.REQUEST_XML)
    columns "ORDER_TYPE" VARCHAR2(30) path '/') xt_res
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://webshop.result.service.soap.CDRator.com/xsd' as "ax2147"
    ),
    'for $i in //ax2147:orderNumber return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "ORDER_NUMBER" NUMBER path '/') xt_rrr;

COMMIT;


END EXT_SOAP_MONITORING;
于 2015-02-12T10:22:08.053 回答