2

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?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
dr jerry
  • 9,768
  • 24
  • 79
  • 122

1 Answers1

9

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;
Tony Andrews
  • 129,880
  • 21
  • 220
  • 259