为什么批量收集到子句是限制pl / sql中嵌套表的大小

时间:2011-10-22 11:23:51

标签: oracle plsql oracle10g oracle11g plsqldeveloper

declare
   type yy is table of t12.name%type;
   y yy:=yy();
   n number:=1;
begin
   y.extend(10);
   select name bulk collect into y from t12;
   --select name into y(5) from t12 where id=1; If i uncomment this line it gives error
   for i in (select name from t12)
   loop
      dbms_output.put_line(y(n));
      n:=n+1;
   end loop;
end;

1 个答案:

答案 0 :(得分:1)

您可以在不首先初始化y的情况下进行测试吗?嵌套表不应该使用批量收集进行初始化。然后,您可以使用extend添加元素。

declare
  type yy is table of t12.name%type;
  y yy;
begin
  select name bulk collect into y from t12;
end;