gpt4 book ai didi

plsql - 游标循环并继续执行: unexpected behaviour

转载 作者:行者123 更新时间:2023-12-04 18:54:33 25 4
gpt4 key购买 nike

由于截止日期的压力,我可能会忽略一些东西。但是这种行为令我惊讶。
好像游标缓存了100行,而continue语句刷新了缓存
并从获取新缓存的第一条记录开始。

我将其范围缩小到以下脚本:

drop table test1;

create table test1 (test1_id NUMBER);

begin
for i in 1..300
loop
insert into test1 values (i);
end loop;
end;
/

declare
cursor c_test1 is
select *
from test1;
begin
for c in c_test1
loop
if mod(c.test1_id,10) = 0
then
dbms_output.put_line(c_test1%ROWCOUNT||' '||c.test1_id||' Continue');
continue;
end if;
dbms_output.put_line(c_test1%ROWCOUNT||' '||c.test1_id||' Process');
end loop;
end;
/

1 1 Process
2 2 Process
3 3 Process
4 4 Process
5 5 Process
6 6 Process
7 7 Process
8 8 Process
9 9 Process
10 10 Continue **Where are tes1_id's 11 to 100?**
11 101 Process
12 102 Process
13 103 Process
14 104 Process
15 105 Process
16 106 Process
17 107 Process
18 108 Process
19 109 Process
20 110 Continue **Where are tes1_id's 111 to 200?**
21 201 Process
22 202 Process
23 203 Process
24 204 Process
25 205 Process
26 206 Process
27 207 Process
28 208 Process
29 209 Process
30 210 Continue **Where are tes1_id's 211 to 300?**


Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
redhat release 5
2 node RAC

最佳答案

是一个错误:7306422

帕维尔·巴鲁(Pawel Barut)写道:
http://pbarut.blogspot.com/2009/04/caution-for-loop-and-continue-in-oracle.html

解决方法:
SQL> ALTER SESSION设置PLSQL_OPTIMIZE_LEVEL = 1;

问候,

关于plsql - 游标循环并继续执行: unexpected behaviour,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/968854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com