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

Updating a column by 8%


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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: 6966
Location: porcelain throne

PostPosted: Tue Apr 01, 2008 12:40 pm
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts first column truncated in search result IBM Tools 13
No new posts Split a record with data in a differe... DFSORT/ICETOOL 8
Search our Forums:

Back to Top