Results 1 to 3 of 3

Thread: Cyclic Updating

  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    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


  2. #2
    Junior Member
    Join Date
    Jan 2007
    Answers
    8

    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.


  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact