开发者

How to initialize a varray table of {TABLE}%ROWTYPE?

I have a varray defined like:

declare
    TYPE tnr_l IS VARRAY(30) of lve%ROWTYPE;

I want this varray to be initialized with a fetch from the database:

select * into tnr_l from lve where type = 'TNR' order by value;

But this fails with:

.ORA-06550: line 6, column 23:
PLS-00321: expression 'TNR_L' is inappropriate as the left hand side of an
assignment statement

How can I make this work开发者_开发百科?


You need to declare a variable of the type tnr_l, and then you need to use bulk collect in the select like this example:

declare
  type t_dept is varray(100) of dept%rowtype;
  l_dept t_dept;
begin
  select * bulk collect into l_dept from dept;
  for i in 1..l_dept.count loop
    dbms_output.put_line(l_dept(i).dname);
  end loop;
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜