Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us