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 SKIP LOCKED DATA in UPDATE statement DB2 9
No new posts Group comparison/update between two f... DFSORT/ICETOOL 10
This topic is locked: you cannot edit posts or make replies. Parsing more than 1000 columns in a s... SYNCSORT 10
No new posts Export columns from DB2 table with pi... DB2 14
No new posts position, start pos, length of column... SYNCSORT 14
Search our Forums:

Back to Top