ORA-00904 无效标识符即使列存在

ORA-00904 invalid identifier even the column exists

我有一个查询,我想在其中生成 SUBSCRIPTION_ID,ORDER_NUMBER.The 查询正在运行 fine.But 我现在还想显示 START_DATE 当 SUBSCRIPTION_ID 被创建。但此后我收到错误消息:

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))

问题是 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))

显然我还没有测试过...

FROM 子句中不存在 table WF。你不能 SELECT 这个 table.

也许你想要这样的东西:

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)