批量dml会用到这两个,主要原理是加速SQL执行速度,原理是利用内存运算和减少sql引擎和plsql引擎的交互
伪代码如下:
1.不利用游标限制单次引擎的交互
declare
--定义记录变量或者rowtype类型
type rec is record(a varchar2(10),
b varchar2(8));
--定义嵌套表或者关联数组
type nest_table is table of rec;
--定义嵌套表或者关联数组对象
t_rec nest_table;
begin
select level,level+1 bulk connect into t_rec
from dual connect by level<=10000;
Forall i in 1..t_rec.count
update table table_name
set column_name= t_rec(i).a
where column_name1= t_rec(i).b;
commit;
end;
/
–游标写法
declare
--定义记录变量或者rowtype类型
type rec is record(a varchar2(10),
b varchar2(8));
--定义嵌套表或者关联数组
type nest_table is table of rec;
--定义嵌套表或者关联数组对象
t_rec nest_table;
begin
cursor cur is select level,level+1
from dual connect by level<=10000;
fetch cur bulk connect into t_rec limit 100;
Fora