比如问题:
将emp表中所有员工的sal修改为100;
解决方法一:
declare
cursor cur is select empno from emp;
begin
for i in cur loop
update test_plan set sal=100 where empno=i.empno;
end loop;
commit;
end;
-----------------------------
方法二:
declare
type tp is table of test_plan.empno%type;
v_tp tp;
cursor cur is select empno from test_plan;
begin
open cur;
fetch cur bulk collect into v_tp;
close cur;
forall i in v_tp.first .. v_tp.last
update test_plan set sal=100 where empno=v_tp(i);
commit;
end;
--------------------
方法三:
declare
type tp is table of test_plan.empno%type;
v_tp tp;
begin
select empno bulk collect into v_tp from emp;
forall i in v_tp.first .. v_tp.last
update test_plan set sal=100 where empno=v_tp(i);
commit;
end;
哪种比较合适?