How to retrieve the output from multilevel table type in Oracle
Below is package spec
create or replace PACKAGE pack
AS
TYPE rec IS RECORD (
name varchar2(240)
);
TYPE t IS TABLE OF rec;
TYPE rec1 IS RECORD (
col1 varchar2(240),
col2 varchar2(240),
col3 t,
col4 t);
type t1 is TABLE OF rec1;
PROCEDURE proc(
p_result OUT t1
);
end;
In package body proc is defined to populate output variable t1.
DECLARE
p_result_out pack.t1;
n_node_type_cnt
BEGIN
p_result_out:=t1();
pack.proc(p_result_out);
n_node_type_cnt:=p_result_out.first;
--dbms_output.put_line (p_result_out(1).col1 );
/*
FOR i IN p_result_out.first .. p_result_out.last
loop
--dbms_output.put_line (p_result(i).col1 );
null;
end loop; */
end;
encountered with below error message
ORA-06531: Reference to uninitialized collection
ORA-06512: at line 17
06531. 00000 - "Reference to uninitialized collection"
*Cause: An element or member function of a nested table or varray
was referenced (where an initialized collection is needed)
without the collection having been initialized.
*Action: Initialize the collection with an appropriate constructor
or whole-object assignment.
Thanks in advance