IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

about swapping in table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandeep4u

New User


Joined: 12 Aug 2005
Posts: 32

PostPosted: Fri Aug 12, 2005 2:27 pm
Reply with quote

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? icon_question.gif icon_question.gif icon_question.gif
Back to top
View user's profile Send private message
Karthikt

New User


Joined: 15 Aug 2005
Posts: 51

PostPosted: Thu Aug 18, 2005 6:37 pm
Reply with quote

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
View user's profile Send private message
sandeep4u

New User


Joined: 12 Aug 2005
Posts: 32

PostPosted: Fri Aug 19, 2005 2:23 pm
Reply with quote

thanks. icon_biggrin.gif icon_biggrin.gif what logic u told is correct but if it i want to solve it by single query how can i go for it? icon_question.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top