日期:2014-05-16  浏览次数:20786 次

求高人解释下面这个执行情况
DECLARE
  TYPE t_oo IS TABLE OF dba_objects.owner%TYPE;
  TYPE t_on IS TABLE OF dba_objects.object_name%TYPE;
  l_oo t_oo;
  l_on t_on;
  tcount number(3) := 0;
  CURSOR c1
  IS
  SELECT owner, object_name
  FROM dba_objects
  WHERE ROWNUM <=1000;
BEGIN
  OPEN c1;
  LOOP

  FETCH c1
  BULK COLLECT INTO l_oo, l_on LIMIT 10000;
  EXIT WHEN c1%NOTFOUND;
tcount := tcount +1 ;
  END LOOP;
  CLOSE c1;
  dbms_output.put_line(tcount);
END;
/

0

PL/SQL 过程已成功完成。


按道理应该出来的结果是1啊,为什么是0啊?


------解决方案--------------------
tcount := tcount +1 ;没执行到

 BULK COLLECT INTO l_oo, l_on LIMIT 10000;
 tcount := tcount +1 ;
 EXIT WHEN c1%NOTFOUND;
------解决方案--------------------
正解。
探讨
tcount := tcount +1 ;没执行到

BULK COLLECT INTO l_oo, l_on LIMIT 10000;
tcount := tcount +1 ;
EXIT WHEN c1%NOTFOUND;