Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am
No new posts Adding a userid to SMTP Security table Yolanda Harvey JCL & VSAM 1 Sun Aug 13, 2017 6:16 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us