Stored Procedures in PL SQL

This stored procedure updates an employee's salary and bonus based on the rating. To create this procedure, download  sp_update_sal.sql (view source) and run: 

db2 -td@ -f sp_update_sal.sql

("-td@" tells cmdline processor '@' will be the statement termination character in the file.)

1. To test, first run a SQL query to find current salary and bonus for employee 000010:

select salary, bonus from employee where empno ='000010' 

2. Execute the stored procedure:

CALL UPDATE_SAL('000010', 2)

3. Check the salary and bonus after the update:

 

select salary, bonus from employee where empno ='000010' 

Make sure you have the right schema for the employee table – change the schema of the tables to your own schema in your database, and also change the user to your local database user name.