문제

마감일 스트레스로 인해 무언가가 간과 될 수 있습니다. 그러나이 행동은 나를 놀라게합니다. 마치 커서가 100 행을 캐시하고 계속 명령문이 캐시를 플러시하고 새 캐시 페치의 첫 번째 레코드로 시작합니다.

다음 스크립트로 좁혔습니다.

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 Set PLSQL_OPTIMIZE_LEVEL = 1;

안부, Rob

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top