00904无效的标识符

00904无效的标识符

我有要生成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))

最佳答案

问题在于,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))

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

关于sql - ORA-00904无效的标识符,即使该列存在,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28344429/

10-11 02:52