我的varray定义如下:
declare
TYPE tnr_l IS VARRAY(30) of lve%ROWTYPE;
我希望通过数据库中的提取来初始化此varray:
select * into tnr_l from lve where type = 'TNR' order by value;
但这失败了:
.ORA-06550: line 6, column 23:
PLS-00321: expression 'TNR_L' is inappropriate as the left hand side of an
assignment statement
我该如何做到这一点?
答案 0 :(得分:8)
您需要声明类型为tnr_l的变量,然后您需要在select中使用bulk collect
,如下例所示:
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;