Q:

Create a PL/SQL block to increase salary of employees in the department 50 using WHERE CURRENT OF clause

0

Create a PL/SQL block to increase salary of employees in the department 50 using WHERE CURRENT OF clause.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

DROP TABLE emp_temp;

CREATE TABLE emp_temp AS
  SELECT employee_id,
         first_name,
         last_name,
		 department_id,
         salary
  FROM   employees;

DECLARE
    CURSOR employee_cur IS
      SELECT employee_id,
             salary
      FROM   emp_temp
      WHERE  department_id = 50
      FOR UPDATE;
    incr_sal NUMBER;
BEGIN
    FOR employee_rec IN employee_cur LOOP
        IF employee_rec.salary < 15000 THEN
          incr_sal := .15;
        ELSE
          incr_sal := .10;
        END IF;

        UPDATE emp_temp
        SET    salary = salary + salary * incr_sal
        WHERE  CURRENT OF employee_cur;
    END LOOP;
END;
/ 

Sample Output:

SQL> /

PL/SQL procedure successfully completed.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now