Create a stored procedure called INCREASE_SALARY to increase all employees’ sala
ID: 3862188 • Letter: C
Question
Create a stored procedure called INCREASE_SALARY to increase all employees’ salaries in a department. The procedure should receive the following two parameters: department number and salary increase amount. The new salary for an employee is calculated based on the following formula: New salary = Old salary + Increase amount.
Including the following two exceptions in the procedure:
If the department number provided is not in the DEPTNO column, generate a message “This department doesn’t exist.”
If the salary increase amount is less than 100 or greater than 1000, then generate a message “The specified amount is invalid.”
The Solution posted on this website is incorrect so it needs to be corrected please.
Explanation / Answer
create or replace PROCEDURE INCREASE_SALARY(deptno IN number, inc_salary IN number) IS
ex_invalid_salary EXCEPTION;
BEGIN
if inc_salary < 100 or inc_salary > 1000 then
RAISE ex_invalid_salary;
end if;
UPDATE department SET Salary = Salary + inc_salary where department_no = deptno;
EXCEPTION
WHEN ex_invalid_id THEN
dbms_output.put_line('Increment salary should be between 100 and 1000');
WHEN no_data_found THEN
dbms_output.put_line('No such department exist!');
END;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.