PL/SQL提供为update和delete语句在cursor中使用提供了where current of子句。这个子句让你容易地进行update和delete操作对最近fetch的行进行操作。
语法:
UPDATE table_name
SET set_clause
WHERE CURRENT OF cursor_name;
DELETE
FROM table_name
WHERE CURRENT OF cursor_name
-- where current of cursor
declare
cursor
cemp is
select * from employees
for update;--要结合for update使用 vemp cemp%rowtype;
begin
open cemp;
loop
fetch cemp into vemp;
exit when cemp%notfound;
update employees set salary=salary*1.2
where current of cemp;--where current of
end loop;
commit;
close cemp;
end;