如何从PL / SQL游标循环中的表中删除行?猜猜,我对这段代码做错了什么:
DECLARE
CURSOR myCursor IS SELECT * FROM A WHERE <some-condition> FOR UPDATE;
BEGIN
FOR x IN myCursor LOOP
DELETE FROM A WHERE CURRENT OF myCursor;
END LOOP;
END;
如果我用DELETE
替换UPDATE
语句,一切都按预期工作(除此之外,记录只会更新而不是删除)。例如:
DECLARE
CURSOR myCursor IS SELECT * FROM A WHERE <some-condition> FOR UPDATE;
BEGIN
FOR x IN myCursor LOOP
UPDATE A SET FOO = 'bar' WHERE CURRENT OF myCursor;
END LOOP;
END;