begin
for(。。。)loop
begin
insert into tbl values (1,'a','b');
exception when others then --插入异常,不管什么,记录日志。
insert into log_temp(tb_name,pk)values('tbl',1,othervalues);
end;
end loop;
end;
[/Quote]
begin
for(。。。)loop
begin
insert into tbl values (1,'a','b');
exception when others then --插入异常,不管什么,记录日志。
insert into log_temp(tb_name,pk)values('tbl',1,othervalues);
end;
end loop;
end;
大批量数据处理的时候,使用forall,比如10000条。
forall i in 1 .. 10000 save exceptions
insert into t values(n(i));
exception when others then
dbms_output.put_line('Errors count:'||sql%bulk_exceptions.count);
for i in 1 .. sql%bulk_exceptions.count loop
dbms_output.put_line('index:' || sql%bulk_exceptions(i).error_index);
dbms_output.put_line('ecode:' || sql%bulk_exceptions(i).error_code);
end loop;
end;