Encode a procedure that receives as parameters a department number, an amount and a percentage and that raises the salary to all the employees of the department indicated in the call. The increase will be the percentage or amount indicated in the call (whichever is the most beneficial for the employee in each case). Indicate when finishing the number of updated rows.
CREATE OR REPLACE PROCEDURE actualizacion (numeroDepartamento NUMBER, importe NUMBER, porcentaje NUMBER) AS CURSOR c_empleados IS SELECT salario FROM emple WHERE dept_no=numeroDepartamento FOR UPDATE; v_regEmpleados c_empleados%ROWTYPE; v_importe NUMBER(3); v_porcentaje NUMBER(4,1); BEGIN OPEN c_empleados; FETCH c_empleados INTO v_regEmpleados; WHILE c_empleados %FOUND LOOP v_porcentaje:=(v_regEmpleados.salario/100)*porcentaje; v_importe:=v_regEmpleados.salario+importe; IF (v_importe > v_porcentaje) THEN UPDATE emple SET salario=salario+v_importe WHERE CURRENT OF c_empleados; ELSE UPDATE emple SET salario=salario+v_porcentaje WHERE CURRENT OF c_empleados; END IF; FETCH c_empleados INTO v_regEmpleados; END LOOP; CLOSE c_empleados; END;
I can not find the error, and I do not know where I would have to put% rowcount to tell me the updated rows.