I have 2 select statement in which i want to use the result of this statement as ALIAS in Select query in order to get the result. But i am getting error in the last line of my query as ORA-00933: SQL command not properly ended
. I dont know what i am missing. Here is my query:
Select(SELECT xt.id
FROM 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 "ID" number path '/')) AS xt,
(SELECT xx.id
FROM SOAP_MONITORING sm
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 "ID" VARCHAR2(30) path '/')) AS xx
FROM SOAP_MONITORING
where WEB_SERVICE_NAME='RatorWebShopService' and WEB_METHOD_NAME='placeShopOrder' and xx.id = 'NEW' ;
You don't need to do subqueries, you can have two XMLTable clauses from the same passing
target:
SELECT xt_res.id
FROM 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 "ID" number path '/') xt_res
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_req
where sm.WEB_SERVICE_NAME='RatorWebShopService'
and sm.WEB_METHOD_NAME='placeShopOrder'
and xt_req.order_type = 'NEW' ;
ID
---------------------
201501070917439804
201501070917439804
That's using the sample XML from your previous question, including the request from the rolled-back edit, both cleaned up to be valid...
Based on discussion that continued in chat , to get data from your wf_workflow
table for the IDs this matches, you can either use a join
:
SELECT wf.* from
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 "ID" number path '/') xt_res
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_req
JOIN WF_WORKFLOW wf
on wf.SUBSCRIPTION_ID = xt_res.id
where sm.WEB_SERVICE_NAME='RatorWebShopService'
and sm.WEB_METHOD_NAME='placeShopOrder'
and xt_req.order_type = 'NEW'
and WF.NAME='INITIATE_MANDATE'
and WF.STATUS_ID=0;
Or include the earlier query as an in
clause; which might be easier to understand but is functionally equivalent (other than suppressing duplicates, which you said you won't have), and might have different performance to the join
version:
SELECT wf.*
from WF_WORKFLOW wf
where wf.SUBSCRIPTION_ID in (
select xt_res.id
from 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 "ID" number path '/') xt_res
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_req
where sm.WEB_SERVICE_NAME='RatorWebShopService'
and sm.WEB_METHOD_NAME='placeShopOrder'
and xt_req.order_type = 'NEW'
)
and WF.NAME='INITIATE_MANDATE'
and WF.STATUS_ID=0;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.