1

I need to use this query in update statement

UPDATE RUN_RESULT 
SET UNQKEY = ( 
                select UNQKEY_VALUE 
                from ( 
                  select distinct RUN_ID,
                           TOCID, 
                         'UNQKEY' || r as UNQKEY , 
                           TOCNAME,
                           UNIQUENESS_COLUMN_ID, 
                         DECODE( r, 1, UNQKEY1, 2, UNQKEY2, 3, UNQKEY3, 4, UNQKEY4 , 5, UNQKEY5) AS UNQKEY_VALUE 
                  from TOC TOC,
                    RULE RL, 
                     RUN_RESULT RR,
                   (select rownum r 
                      from all_objects 
                      where rownum <=5) 
                WHERE RL.RULE_SET_ID=RR.RULE_SET_ID 
                AND TOC.TOCID= RR.TOC_ID ) t 
          WHERE UNIQUENESS_COLUMN_ID like UNQKEY
          and UNQKEY_VALUE IS NOT NULL ) 
      Where ????? 

I have to use the inner query column like RUN_ID,TOCID, how to access in the inner query columns

APC
  • 144,005
  • 19
  • 170
  • 281
Jey
  • 107
  • 2
  • 12
  • Would you mind formatting your question so we can actually read it? – Patrick Hofman Jul 25 '14 at 15:02
  • What do you mean by "access in the inner query columns". What exactly are you trying to accomplish here? – C.J. Jul 25 '14 at 15:05
  • Are you just looking to use `t.RUN_ID` and `t.TOCID` in that last `WHERE` clause? Why would you need it there and not filter within the inner query already? – Mike Guthrie Jul 25 '14 at 15:10
  • You can't do that. You will need to restructure your query. Refer http://stackoverflow.com/questions/2446764/oracle-update-statement-with-inner-join – TMNT2014 Jul 25 '14 at 15:13
  • If you can join to your inner query instead of selecting from it, you can access all of its columns in the outer query. – Tab Alleman Jul 25 '14 at 15:21
  • @ Mike Guthrie, I need to do an update based on some condition. – Jey Jul 28 '14 at 16:09

0 Answers0