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
 

 

Update table to swap the valus of 'c' and 'd'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Mahua Mitra

New User


Joined: 26 Apr 2007
Posts: 49
Location: Delhi

PostPosted: Fri Aug 17, 2007 4:40 pm    Post subject: Update table to swap the valus of 'c' and 'd'
Reply with quote

I have a table with Clumns a,b,c,d,e and date-timestamp. I need to swap the valus of 'c' and 'd' when Date-timestamp <= '2005-05-13-00.00.00.000000'.

All th 5 columns (a,b,c,d,e) make composite primary ky. I need to do it through sql query

Can ne1 pleas hlp me.

Thanks in advance
Back to top
View user's profile Send private message

Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Fri Aug 17, 2007 5:14 pm    Post subject: Reply to: Update table to swap the valus of 'c' and 'd'
Reply with quote

Can you try out this one?

update table t1 set c = (select d from tabel t2
where t2.a = t1.a
and t2.b = t1.b
and t2.c = t1.c
and t2.d = t1.d ),
d = (select d from tabel t3
where t3.a = t1.a
and t3.b = t1.b
and t3.c = t1.c
and t3.d = t1.d ),
where t1.timestamp <= '2005-05-13-00.00.00.000000'

Thanks,
Prajesh
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Thu Aug 23, 2007 5:17 am    Post subject: Reply to: Update table to swap the valus of 'c' and 'd'
Reply with quote

apparently the OP never did.
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
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 IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


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