PL/SQL- Procedure to calculate 10 percent interest of salary

Viewed 35

For example in hr schema I have to compute and update the interest. Let's say I have an interest of 10 percent, I have to compute that with the salary (Salary*.10) for those employees whose job is 'SA_MAN'. Then the data in the tables should be updated.

So I duplicate the employees table into employees_copy where I added another table which is the interest, I want to create a procedure where it will calculate 10% interest with salary (Salary*.10) but I'm not familiar with the format of the procedure, plus with the condition of the department name 'SA_MAN'.

1 Answers

You do not need to copy the table or create an additional table; to increase the salary of employees with the SA_MAN job by 10% then use an UPDATE statement:

UPDATE employees
SET   salary = salary * 1.10
WHERE job = 'SA_MAN'

If you want it in a procedure then:

CREATE PROCEDURE increase_salary (
  i_percent IN NUMBER,
  i_job     IN VARCHAR2
)
IS
BEGIN
  UPDATE employees
  SET   salary = salary * (1 + i_percent/100)
  WHERE job = i_job;
END;
/
Related