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 unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


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