Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 从clob数据类型xml值中提取数据_Sql_Xml_Oracle_Xml Namespaces - Fatal编程技术网

Sql 从clob数据类型xml值中提取数据

Sql 从clob数据类型xml值中提取数据,sql,xml,oracle,xml-namespaces,Sql,Xml,Oracle,Xml Namespaces,我有以下xml值,它存储在request_xml列中,是clob数据类型: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns:updateRechargeTicketResponse xmlns:ns="http://ser

我有以下xml值,它存储在request_xml列中,是clob数据类型:

  <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:updateRechargeTicketResponse xmlns:ns="http://service.soap.CDRator.com">
      <ns:return xmlns:ax232="http://core.result.service.soap.CDRator.com/xsd" xmlns:ax233="http://core.data.soap.CDRator.com/xsd" xmlns:ax230="http://payment.result.service.soap.CDRator.com/xsd" xmlns:ax228="http://data.soap.CDRator.com/xsd" xmlns:ax231="http://result.service.soap.CDRator.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax230:RechargeTicketResultDTO">
        <ax233:id xsi:nil="true"/>
        <ax232:code>0</ax232:code>
        <ax232:description>SOAP_GLOBAL_SUCCESS</ax232:description>
        <ax232:serviceUser xsi:nil="true"/>
        <ax232:success>true</ax232:success>
        <ax232:translationTag>SOAP_GLOBAL_SUCCESS</ax232:translationTag>
        <ax230:rechargeTicket xsi:type="ax228:RechargeTicketDTO">
          <ax233:id>201505131421267777</ax233:id>
          <ax233:billingGroupId>201505071857272816</ax233:billingGroupId>
          <ax233:code>BALANCE_DIRECTDEBIT</ax233:code>
          <ax233:dateCreated>2015-05-13</ax233:dateCreated>
          <ax233:dayOfMonth>0</ax233:dayOfMonth>
          <ax233:nextRechargeDate xsi:nil="true"/>
          <ax233:rechargeAmount>10.0</ax233:rechargeAmount>
        </ax230:rechargeTicket>
      </ns:return>
    </ns:updateRechargeTicketResponse>
  </soapenv:Body>
</soapenv:Envelope>
这是我的问题

   SELECT ID,CREATE_DATE,WEB_SERVICE_NAME,WEB_METHOD_NAME,xt_billingGroupId.BILLING_GROUP_ID,xt_error_code.ERROR_CODE,xt_error_message.ERROR_DESCRIPTION,xt_code.CODE,xt_rec_id.RECHARGE_TICKET_ID
FROM TEMP_SOAP_MONITORING_TOPUP 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",
      'http://core.signup.data.soap.CDRator.com/xsd' as "ns3",
      'http://service.soap.CDRator.com' as "ns5",      
      'http://core.data.soap.CDRator.com/xsd' as "ax233",
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //*:billingGroupId return $i'
    passing XMLType(sm.REQUEST_XML)
    columns "BILLING_GROUP_ID" VARCHAR2(100) path '/') xt_billingGroupId    
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //ax232:code return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "ERROR_CODE" VARCHAR2(100) path '/') xt_error_code 
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //ax232:description return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "ERROR_DESCRIPTION" VARCHAR2(200) path '/') xt_error_message
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    ),
    'for $i in //*:code return $i'
    passing XMLType(sm.REQUEST_XML)
    columns "CODE" VARCHAR2(100) path '/') xt_code
CROSS JOIN XMLTable(XMLNAMESPACES (
      'http://core.data.soap.CDRator.com/xsd' as "ax233"
    ),
    'for $i in //ax230:rechargeTicket  return $i'
    passing XMLType(sm.RESPONSE_XML)
    columns "RECHARGE_TICKET_ID" VARCHAR2(200) path 'ax233:id') xt_rec_id

您的名称空间在源XML和查询上不匹配

'http://data.soap.CDRator.com/xsd' as "ax233"
vs

尝试从源代码中删除
core.
,或者为
ax233
core.
添加到
XMLNAMESPACES


要修复错误,请执行以下操作:

ORA-19228: XPST0008 - undeclared identifier: prefix 'ax230' local-name 'ax230:rechargeTicket'
19228. 00000 -  "XPST0008 - undeclared identifier: prefix '%s' local-name '%s'"
您缺少ax230的命名空间声明,因此需要向XMLNAMESPACES添加:

'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",

如果查询的格式更好,您可能会发现它更容易(除非您有理由这样做)。有关示例,请参见以下内容:

SELECT 
  t.error_code
, t.error_description
, t.code
FROM temp_soap_monitoring_topup sm
, 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",
      'http://core.signup.data.soap.CDRator.com/xsd' as "ns3",
      'http://service.soap.CDRator.com' as "ns5",
      'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",      
      'http://core.data.soap.CDRator.com/xsd' as "ax233",
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    )
  , 'soapenv:Envelope/soapenv:Body/ns:updateRechargeTicketResponse/ns:return'
  PASSING XMLTYPE(sm.response_xml)
  COLUMNS
    error_code        VARCHAR2(100) PATH 'ax232:code/text()'
  , error_description VARCHAR2(100) PATH 'ax232:description/text()'
  , code              VARCHAR2(100) PATH 'ax230:rechargeTicket/ax233:code/text()'
  ) t

我已将您的XML放在本地数据库的一个表中,替换为
http://data.soap.CDRator.com/xsd'作为“ax233”,
'http://core.data.soap.CDRator.com/xsd'作为“ax233”,
我正在取回ID您好,我已经编辑了我的问题。当我仅使用此条件进行测试时,它工作正常,但现在我已经完成了完整的查询,它给出了一个错误。你能告诉我为什么它会出错吗?请查看我上次在查询中的交叉连接,其中有一个错误。请参阅我的编辑-您现在的查询中缺少ax230命名空间。在做了简短的整理后,再次编辑。您可以在两个XMLTables中执行此操作,一个用于请求xml,另一个用于响应xml。适当地构建路径,然后按照简单的相对路径选择多个列。
'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",
SELECT 
  t.error_code
, t.error_description
, t.code
FROM temp_soap_monitoring_topup sm
, 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",
      'http://core.signup.data.soap.CDRator.com/xsd' as "ns3",
      'http://service.soap.CDRator.com' as "ns5",
      'http://payment.result.service.soap.CDRator.com/xsd' as "ax230",      
      'http://core.data.soap.CDRator.com/xsd' as "ax233",
      'http://core.result.service.soap.CDRator.com/xsd' as "ax232"
    )
  , 'soapenv:Envelope/soapenv:Body/ns:updateRechargeTicketResponse/ns:return'
  PASSING XMLTYPE(sm.response_xml)
  COLUMNS
    error_code        VARCHAR2(100) PATH 'ax232:code/text()'
  , error_description VARCHAR2(100) PATH 'ax232:description/text()'
  , code              VARCHAR2(100) PATH 'ax230:rechargeTicket/ax233:code/text()'
  ) t