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
 

 

Updating a column by 8%

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

New User


Joined: 21 Feb 2008
Posts: 18
Location: Mumbai

PostPosted: Tue Apr 01, 2008 12:31 pm    Post subject: Updating a column by 8%
Reply with quote

Hi,

I am new to DB2. I want to update column by 8%. Can anybody let me know, how we can do this. Suppose my table is

TABLE: EMP

EMP_ID SALARY
30301 50000
50010 20000
40010 40000

I want to increase SALARY by 8%.

Can anybody help me in this.Thanks in advance.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Apr 01, 2008 12:40 pm    Post subject:
Reply with quote

SET SALARY = SALARY + .08(SALARY)?
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Tue Apr 01, 2008 12:58 pm    Post subject:
Reply with quote

UPDATE EMP SET SALARY = SALARY * 1.08
Back to top
View user's profile Send private message
chiru_sh

New User


Joined: 21 Feb 2008
Posts: 18
Location: Mumbai

PostPosted: Tue Apr 01, 2008 4:54 pm    Post subject: Reply to: Updating a column
Reply with quote

Thanks you very much...in COBOL whether i need to declare cursor or directly i can give this query.....
Back to top
View user's profile Send private message
Richa Jain

New User


Joined: 18 Mar 2008
Posts: 35
Location: Gurgaon

PostPosted: Tue Apr 01, 2008 5:09 pm    Post subject:
Reply with quote

Yes, you can use it directly in a cobol program.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Tue Apr 01, 2008 10:40 pm    Post subject:
Reply with quote

usually CURSORS are not required for updation of the table. They are used while fetching the records from the table.
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Wed Apr 02, 2008 9:43 am    Post subject:
Reply with quote

Quote:
usually CURSORS are not required for updation of the table



Note that UPDATE operations can be performed in one of two ways:

1) By performing a searched update operation

Ex: UPDATE EMPLOYEES SET SALARY = NULL

UPDATE EMPLOYEES SET SALARY = SALARY * 1.08
WHERE EMP_ID = 30301

2) By performing a positioned update operation.

To perform a positioned update, a cursor must first be created, opened, and positioned on the row that is to be updated. Then, the UPDATE statement that is to be used to modify one or more data values must contain a WHERE CURRENT OF [CursorName] clause (CursorName identifies the cursor being used—we'll look at cursors shortly). Because of their added complexity, positioned update operations are typically performed by embedded SQL applications.

EXEC SQL
UPDATE EMP
SET SALARY = :WS-SALARY
WHERE CURRENT OF CURSOR_1
END-EXEC
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Apr 02, 2008 12:00 pm    Post subject: Re: Reply to: Updating a column
Reply with quote

chiru_sh wrote:
Thanks you very much...in COBOL whether i need to declare cursor or directly i can give this query.....


I'd go for the CURSOR option (+Commit) in case the number of rows afected is high...it could be other programs couldn't access that table.
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 Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am


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