0

please help me with this "for update of" and "current of" clause in the cursors... though the cursor is able to fetch the records getting an error saying invalid rowid.

DECLARE
  CURSOR C_EMP IS SELECT * FROM emp FOR UPDATE OF SAL;--LOCKING MEANS WE CANNOT MAKE ANY CHANGES ON THIS COLUMN WHILE THIS CODE IS RUNNING
BEGIN
  FOR R_EMP IN C_EMP LOOP
  IF R_EMP.SAL<5000 AND C_EMP%FOUND THEN
  UPDATE EMP2 SET SAL=SAL*1.1 WHERE CURRENT OF C_EMP;
  END IF;
  END LOOP;
END;
4

1 回答 1

2

假设您真的想更新另一个表 (EMP2) 而不是 EMP,那么您不能使用 where current of 更新另一个表,因为 rowid 不匹配。

其中 current of 表示“我们正在处理的 rowid”。相反,您必须加入正确的列而不是该子句

于 2013-04-04T14:43:49.033 回答