2

私は次のように定義された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

どうすればこれを機能させることができますか?

4

1 に答える 1

8

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;
于 2010-11-08T10:30:58.967 に答える