プロシージャ内のコレクションからいくつかの値をテーブルに挿入する必要がありますが、ORA-00902: invalid datatype
エラーが発生します。
これはターゲット テーブルです。
create table t_test (col01 number, col02 number);
コレクションのタイプとパイプライン関数をパッケージで定義しています。
create or replace package p_test is
type t_num is table of number;
function rtn(arg_tn t_num) return t_num PIPELINED;
end p_test;
/
create or replace package body p_test is
function rtn(arg_tn t_num) return t_num PIPELINED is
tn_row number;
begin
for i in arg_tn.first .. arg_tn.last loop
tn_row := arg_tn(i);
pipe row(tn_row);
end loop;
return;
end;
end p_test;
これが私の PL/SQL プロシージャです。
declare
tn_test p_test.t_num := p_test.t_num(10,20,30);
n_num number := 69;
begin
insert into T_TEST(col01, col02) select n_num, column_value from table(tn_test);
end;
結果のテーブルは次のようになります。
col01 | col02
-------|-------
69 | 10
69 | 20
69 | 30
そして、これは私が得ているエラーです:
私は何を間違っていますか?修正方法は?サイクルでこれを行うこともできましたfor
が、必要な目的に対して非効率的すぎませんか?