从 clob 数据类型 xml 值中提取数据
Extract the data from clob data type xml value
我有以下 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>
我想从 中提取值。我使用了下面的查询,但它 returns nothing.I 收到一个错误
ORA-19228: XPST0008 - undeclared identifier: prefix 'ax230' local-name 'ax230:rechargeTicket'
19228. 00000 - "XPST0008 - undeclared identifier: prefix '%s' local-name '%s'"
这是我的查询
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"
对
xmlns:ax233="http://core.data.soap.CDRator.com/xsd"
尝试从您的来源中删除 core.
或将 core.
添加到您的 XMLNAMESPACES
for ax233
.
修复错误:
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 值,它存储在 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>
我想从 中提取值。我使用了下面的查询,但它 returns nothing.I 收到一个错误
ORA-19228: XPST0008 - undeclared identifier: prefix 'ax230' local-name 'ax230:rechargeTicket'
19228. 00000 - "XPST0008 - undeclared identifier: prefix '%s' local-name '%s'"
这是我的查询
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"
对
xmlns:ax233="http://core.data.soap.CDRator.com/xsd"
尝试从您的来源中删除 core.
或将 core.
添加到您的 XMLNAMESPACES
for ax233
.
修复错误:
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