Prepare for your Next Interview
This is a discussion on Cyclic Updating within the Oracle forums, part of the Databases category; There is a table Table_A contains 4 feilds col1, col2, col3, col4 having values a, b, c, d as values respectively. What will be the code if someone wants to ...
|
|||
|
Cyclic Updating
There is a table Table_A contains 4 feilds col1, col2, col3, col4 having values a, b, c, d as values respectively. What will be the code if someone wants to update a with b, b with c, c with d and d with a ?
NOTE : This question was asked by sha_jit |
| Sponsored Links |
|
|||
|
Re: Cyclic Updating
Hai,
how abt this code? begin select col1 into :temp from table_1 where col1 = 'a'; update table_1 set col1=col2,col2=col3,col3=col4,col4=:temp where col1='a'; end; here, ":temp" is the bind variable. This code is very specific to the question. This works when col2's datatype is compatible with the col1's datatype and so.. And may I know where we could find situation like this? Regards, Bhuvana. |
|
|||
|
Re: Cyclic Updating
Update cyclic1 set col1= decode(col1,'a','b'),col2=decode(col2,'b','c'),col3=decode(col3,'c','d'),
col4=decode(col4,'d','a') or Update cyclic1 set col1= decode(col1,col1,col2),col2=decode(col2,col2,col3),col3=decode(col3,col3,col4), col4=decode(col4,col4,col1) Try this ...... |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Updating table with group of line items | Lokesh M | SAP R/3 | 0 | 12-10-2006 05:47 AM |