I want to write PL/SQL Procedure that updates salary which is less than 2000. I wrote this procedure.And when i call it with integer id 'ORA-01422: exact fetch returns more than requested number of rows' error is thrown by TOAD. My procedure is like below:
DECLARE
PROCEDURE update_salary(ID customers.id%type) is
c_sal customers.salary%type;
BEGIN
SELECT salary
INTO c_sal
FROM customers
WHERE id = ID;
dbms_output.put_line ('Before update operation salary is:' || c_sal);
--dbms_output.put_line ('Parameter :' || ID);
IF (c_sal <= 2000) THEN
UPDATE customers
SET salary = salary + 1000
WHERE id = ID;
dbms_output.put_line ('Salary updated');
END IF;
SELECT salary
INTO c_sal
FROM customers
WHERE id=ID;
dbms_output.put_line ('After update operation salary is:' || c_sal);
END;
BEGIN
update_salary(1);
END;
/
I print parameter id with dbms_output. The parameter is coming correctly. How can i fix this error !