Andrew Andrew - 4 months ago 22
SQL Question

ORA-00904 invalid identifier even the column exists

I have query in which i want to result the SUBSCRIPTION_ID,ORDER_NUMBER.The query is working fine.But i also want to show now the START_DATE when the SUBSCRIPTION_ID are created. But i am getting an errors after this as :

ORA-00904: "WF"."START_DATE": invalid identifier
00904. 00000 - "%s: invalid identifier"

jpw jpw
Answer

The issue is that the WF_WORKFLOW only is available in the scope of the subquery used for the IN predicate and you're referencing it outside that scope.

I think you could rewrite the query to use a join instead like this:

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

Obviously I haven't tested it...

Comments