我有查询,我希望得到SUBSCRIPTION_ID,ORDER_NUMBER。查询工作正常。但我还想在创建SUBSCRIPTION_ID时显示START_DATE。但是在此之后我得到了一个错误:
ORA-00904: "WF"."START_DATE": invalid identifier
00904. 00000 - "%s: invalid identifier"
这是我的问题:
select iw.SUBSCRIPTION_ID,iw.ORDER_NUMBER,WF.START_DATE
from (
SELECT 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,
CREATE_DATE
FROM
SOAP_MONITORING,WF_WORKFLOW ww
where WEB_SERVICE_NAME='RatorWebShopService' and WEB_METHOD_NAME='placeShopOrder'
) iw
where iw.order_type='NEW' and iw.SUBSCRIPTION_ID IN
(select WF.SUBSCRIPTION_ID
from WF_WORKFLOW WF where WF.NAME='SIGNUP_MOBILE_PRE_PAID'
and WF.STATUS_ID=0 and WF.START_DATE < sysdate - 30 / (24 * 60))
答案 0 :(得分:2)
问题是WF_WORKFLOW
仅在用于IN
谓词的子查询范围内可用,并且您在该范围之外引用它。
我认为您可以重写查询以使用连接,而不是像这样:
select iw.SUBSCRIPTION_ID,iw.ORDER_NUMBER,WF.START_DATE
from (
SELECT 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,
CREATE_DATE
FROM
SOAP_MONITORING,WF_WORKFLOW ww
where WEB_SERVICE_NAME='RatorWebShopService' and WEB_METHOD_NAME='placeShopOrder'
) iw
inner join WF_WORKFLOW WF on iw.SUBSCRIPTION_ID = WF.SUBSCRIPTION_ID
where iw.order_type='NEW'
and WF.NAME='SIGNUP_MOBILE_PRE_PAID'
and WF.STATUS_ID=0 and (WF.START_DATE < sysdate - 30 / (24 * 60))
显然我还没有测试过它......
答案 1 :(得分:1)
FROM子句中不存在表WF。你不能在这张桌子上选择。
可能你想要这样的东西:
FROM (...) iw
INNER JOIN WF_WORKFLOW WF on WF.SUBSCRIPTION_ID=iw.SUBSCRIPTION_ID
WHERE iw.order_type='NEW' AND WF.NAME='SIGNUP_MOBILE_PRE_PAID'
AND WF.STATUS_ID=0 and WF.START_DATE < sysdate - 30 / (24 * 60)