View previous topic :: View next topic
|
Author |
Message |
sandeep4u
New User
Joined: 12 Aug 2005 Posts: 32
|
|
|
|
Hi all,
I have a query about swapping of column values. I have a table with 2 cols c1, c2 in that suppose i have values 10 and 12 respectively. now i want to swap the values how i can do it? |
|
Back to top |
|
|
Karthikt
New User
Joined: 15 Aug 2005 Posts: 51
|
|
|
|
Declare a cursor
DECLARE CURSOR C1 FOR SELECT C1, C2 FROM TABLE WHERE 1>0
OPEN CURSOR C1
loop until sql status code -100
FETCH C1 INTO :WS-C1, :WS-C2
UPDATE TABLE SET FIELDS (C1,C2) VALUES (:WS-C2,:WS-C1)
end-loop
CLOSE CURSOR C1 |
|
Back to top |
|
|
sandeep4u
New User
Joined: 12 Aug 2005 Posts: 32
|
|
|
|
thanks. what logic u told is correct but if it i want to solve it by single query how can i go for it? |
|
Back to top |
|
|
|