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

Updating table through arithmetic function


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

New User


Joined: 08 Aug 2006
Posts: 61
Location: Philippines

PostPosted: Thu Aug 30, 2007 3:07 pm
Reply with quote

How is this done?Is this possible?
I just want to update a specific field in the table wherein I will just have to subtract an amount to that particular field..How is this done?

Such us;

Update table
set table field = (field - 400)

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

Global Moderator


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

PostPosted: Thu Aug 30, 2007 3:12 pm
Reply with quote

yep, except for the syntax you have it right. 'Manuals' hyperlink at the very top of this page, then look for an SQL manual to find out the exact syntax for an update. You should include a WHERE clause to insure that you only UPDATE rows that you want and not all rows in the table.

The parenthesis in the SET statement are not required.
Back to top
View user's profile Send private message
madlui56

New User


Joined: 08 Aug 2006
Posts: 61
Location: Philippines

PostPosted: Thu Aug 30, 2007 3:17 pm
Reply with quote

I will find the document you suggested
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Aug 30, 2007 8:38 pm
Reply with quote

Hello,

Is a negative value valid for "field"?

If not, you would test to make sure that the -400 did not result in a negative value.
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 Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Calling an Open C library function in... CICS 1
Search our Forums:

Back to Top