【发布时间】:2023-03-04 02:09:01
【问题描述】:
今天我遇到了“FETCH OUT OF SEQUENCE”ORA-01002。我做了很多研究,我开始明白这很常见。
- 当我们已经关闭游标时尝试获取。
- 用于更新和提交。
如果处理成功,我的要求是每 500 条记录提交一次,如果出现任何问题,则回滚获取的 500 条记录。
其中任何一个我都没有做过。我还发现由于 ROLLBACK 发生了乱序提取;
我还缩小了实际发生的时间。仅当第一组记录发生回滚时才会发生这种情况。
loop
Fetch c1 bulk collect into type1 limit 500;
exit when type1.count=0;
forall in i..type1.count save exceptions
insert into the table.
do something.....
the computation goes on;
Commit;
exception when others then
for i in 1..sql%bulk_exceptions loop
Do somthing...
end loop;
rollback; => Fetch out of seq happens here...
end loop;
仅当前 500 条记录失败并且我发出回滚命令时才会发生乱序提取。当前 500 条记录被提交并且接下来的 500 条记录被回滚时,它不会给出 ora-01002。
它这样做的任何原因。请建议是否有任何方法可以避免 ora-01002 错误。
很抱歉,由于公司政策,无法在此处发布编码。但是上面给出的伪代码是如何编码的。
附加信息-> 如果我以这种方式执行程序,那么我不会收到错误“ORA-01002”。
loop
Fetch c1 bulk collect into type1 limit 500;
exit when type1.count=0;
COMMIT; => IF I ADD COMMIT HERE ORA-01002 doesnt appear.
forall in i..type1.count save exceptions
insert into the table.
do something.....
the computation goes on;
Commit;
exception when others then
for i in 1..sql%bulk_exceptions loop
Do somthing...
end loop;
rollback; => Fetch out of seq happens here...
结束循环;
【问题讨论】: