0

have the following Update query which gives an error ORA-01747: invalid user.table.column, table.column, or column specification which i am not able to identify. I have the correct syntax i guess but still it gives the error. Here is the query:

Update TEMP_WF_WORKFLOW Set Event_ID=(Select 10003 from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID where TSM.order_type='SELF_REGISTRATION'),
Set Event_ID=(Select 10028 from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID where TSM.order_type='NEW'),    
Set Event_ID=(Select 10078 from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID where TSM.order_type='SELF_REGISTRATION'),
Set Event_ID=(Select 10101 from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID where TSM.order_type='NEW')
Andrew
  • 3,632
  • 24
  • 64
  • 113

1 Answers1

3
Update TEMP_WF_WORKFLOW
  Set Event_ID= case (select TSM.order_type
                      from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM
                        ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID)
                  when 'SELF_REGISTRATION' then 10008
                  when 'NEW' then 10003
                  when 'SELF_REGISTRATION' then 10078
                  when 'NEW' then 10101
                  else Event_ID
                end

This is what you're trying to do! Note that same values are repeated!!!

Why hardcoded integer values?

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Without hardcoding the value how can i update the EVENT_ID column with the values using the condition ? – Andrew Mar 01 '15 at 13:36
  • @Rahul, jarlh is suggesting there ought to be a table where values of `EVENT_ID` correspond to the `ORDER_TYPE` – David Faber Mar 01 '15 at 13:37
  • No there are too many events with the same order type and i dont have separate table for this – Andrew Mar 01 '15 at 13:39
  • @DavidFaber, exactly! Make the query independent of the current set of "codes". – jarlh Mar 01 '15 at 13:40
  • Here is the query i tried but gives an error missing parenthesis :- Update TEMP_WF_WORKFLOW Set Event_ID= case (select TSM.order_type,WF.STATUS_ID,WF.NAME from TEMP_WF_WORKFLOW TWW JOIN TMP_SOAP_MONITORING_IDS TSM ON TSM.SUBSCRIPTION_ID=TWW.SUBSCRIPTION_ID) when ('SELF_REGISTRATION',0,'SIGNUP_MOBILE_PRE_PAID') then 10008 END – Andrew Mar 01 '15 at 13:41
  • @Jarlh sorry to mention in my query that i have 2 more conditions and when i try to use it it gives an error missing parenthesis – Andrew Mar 01 '15 at 13:43
  • You mean 'SELF_REGISTRATION',0,'SIGNUP_MOBILE_PRE_PAID') shall all have 10008? One "when / then " for each type is needed. I.e. when 'SELF_REGISTRATION' then 10008 when 0 then 10008 when etc. But I still think this is the wrong way to go, pick code from another table instead! – jarlh Mar 01 '15 at 13:44
  • I don't think I've seen a tuple used in a `CASE` before. Not sure it would work. – David Faber Mar 01 '15 at 23:11