Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

about swapping in table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: about swapping in table
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    Post subject:
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    Post subject: Thanks! but 1 query
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm
No new posts Getting soc4 on internal table in cobol abdulrafi COBOL Programming 13 Fri May 06, 2016 3:39 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us