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

3 columns update


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

New User


Joined: 01 Apr 2009
Posts: 33
Location: Rome - Italy

PostPosted: Mon Jun 22, 2015 6:43 pm
Reply with quote

hola,
i must update 3 columns (yesterday, today, tomorrow) of table XXX.
the correct value of 'today' in on another table YYY.

This is my actual:
update XXX
set today = (select today from yyy)
, yesterday = (select today from yyy) - 1 day
, tomorrow = (select today from yyy) + 1 day
;

Can I set a variable for the value of today?
I don't want do 3 select on yyy but only 1!

Thanks!!!
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon Jun 22, 2015 11:49 pm
Reply with quote

I have to say I am not sure if this would work but can you try this:

update XXX
set (today, yesterday, tomorrow) = (select today, today - 1 day, today + 1 day from yyy)
;
Right now I don't have any means to test this but if you test (and it works) then please let me know ;-)
Back to top
View user's profile Send private message
Seppe

New User


Joined: 01 Apr 2009
Posts: 33
Location: Rome - Italy

PostPosted: Tue Jun 23, 2015 12:49 pm
Reply with quote

Great!
It's perfect!
Thank you RahulG31
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 Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
No new posts DB2 Views with Multiple SQL & Col... DB2 8
No new posts SORT - To repeat a string in same col... SYNCSORT 3
No new posts JCL - To repeat a string in same colu... JCL & VSAM 2
Search our Forums:

Back to Top