LZ是不是专门在练习怎样使用游标啊,给你一个小例子,不知是不是你要的 declare cursor c is select * from emp2 for update; begin for v_temp in c loop if(v_temp.sal<2000) then update emp2 set sal=sal*2 where current of c; elsif(v_temp.sal=5000) then delete from emp2 where current of c; end if; end loop; commit; end; /
建议直接用update更新不是更好的方法
declare
cursor c is select * from emp2 for update;
begin
for v_temp in c loop
if(v_temp.sal<2000) then
update emp2 set sal=sal*2 where current of c;
elsif(v_temp.sal=5000) then
delete from emp2 where current of c;
end if;
end loop;
commit;
end;
/