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
 

 

3 columns update

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: 3 columns update
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: 331
Location: USA

PostPosted: Mon Jun 22, 2015 11:49 pm    Post subject: Reply to: 3 columns update
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    Post subject:
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    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 -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


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