执行此块时,我收到“ORA-01410:无效的ROWID”异常。有什么想法吗?
DECLARE
CURSOR c_orders IS
SELECT * from orders FOR UPDATE OF no;
v_order_record c_orders%ROWTYPE;
BEGIN
OPEN c_orders;
LOOP
FETCH c_orders INTO v_order_record;
UPDATE orders SET no = 11 WHERE CURRENT OF c_orders;
EXIT WHEN c_orders%NOTFOUND;
END LOOP;
CLOSE c_orders;
END;
但是,如果使用FOR IN语法,一切都有效:
DECLARE
CURSOR c_orders IS
SELECT * from orders FOR UPDATE OF no;
BEGIN
FOR rec IN c_orders
LOOP
UPDATE orders SET no = 11 WHERE CURRENT OF c_orders;
END LOOP;
END;
答案 0 :(得分:4)
将exit when
移至update
之前 - 您无法更新不存在的内容。