Env: Oracle 8.1.7
The following procedure is executed:
--------------------------------------
PROCEDURE proc_name AS
CURSOR cur_name IS
SELECT col1, col2, rowid
FROM table_name;
BEGIN
FOR rec_name IN cur_name LOOP
BEGIN
v_var3 := foo(rec_name.col1, rec_name.col2);
UPDATE table_name
SET col3 = v_var3
WHERE rowid = rec_name.rowid;
END;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
BEGIN
v_err_msg:=SUBSTR(sqlerrm,1,255);
RAISE_APPLICATION_ERROR(-20004,'ERROR: Unable to update table_name '||v_err_msg);
END;
END proc_name;
------------------------------------------
And the following ERRORS are logged:
------------------------------------------
ORA-20001: ORA-20001: ORA-20004: ERROR: Unable to update table_name
ORA-01422: exact fetch returns more than requested number of rows
------------------------------------------
Question:
What's the reason for ORA-01422 in this case, IF the ROWID is used in the UPDATE statement?
Thank you.
<ruse7013>
The following procedure is executed:
--------------------------------------
PROCEDURE proc_name AS
CURSOR cur_name IS
SELECT col1, col2, rowid
FROM table_name;
BEGIN
FOR rec_name IN cur_name LOOP
BEGIN
v_var3 := foo(rec_name.col1, rec_name.col2);
UPDATE table_name
SET col3 = v_var3
WHERE rowid = rec_name.rowid;
END;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
BEGIN
v_err_msg:=SUBSTR(sqlerrm,1,255);
RAISE_APPLICATION_ERROR(-20004,'ERROR: Unable to update table_name '||v_err_msg);
END;
END proc_name;
------------------------------------------
And the following ERRORS are logged:
------------------------------------------
ORA-20001: ORA-20001: ORA-20004: ERROR: Unable to update table_name
ORA-01422: exact fetch returns more than requested number of rows
------------------------------------------
Question:
What's the reason for ORA-01422 in this case, IF the ROWID is used in the UPDATE statement?
Thank you.
<ruse7013>