Example of a Sample Cursor For Loop In PLSQL
Example of a Sample Cursor For Loop In PLSQL
Topic Introduction: This tutorial will give an Example of a Sample Cursor For Loop In PLSQL.
Example#1: Update the gross salary of employees who get a commission.
DECLARE
CURSOR c_gs
IS
SELECT employee_id, salary, commission_pct
FROM employees
WHERE commission_pct IS NOT NULL;
BEGIN
FOR i IN c_gs
LOOP
UPDATE employees
SET gross_salary =
i.salary + i.salary * NVL (i.commission_pct, 0) / 100
WHERE employee_id = i.employee_id;
END LOOP;
END;
No comments