I would like to insert the collection from the out parameter of a different proc into a table using a procedure. Let me give u the code to explain clearly.
Create type t1 is object
Name varchar2 (10),
Address varchar2 (50),
Pin number);
create type t is table of t1;
create procedure PS1 (P1 out t)
Is
TE t := t();
Begin
Te.extend();
Select t1(name, address,pin) bulk
collect into TE
From table1;
-- note: table1 has same table structure as object t1;
End;
Now I have two requirements. For testing purpose, i would like to print one of the data in the collection.
Declare
A t := t();
Begin
a.extend ();
PS1(a);
DBMS.output.put_line(a(1).pin);
-- after completing this a validation will check if the
-- pin has null values.
If a(1).pin is not null
Then
Insert into t2 values (
a(1).name, a(1).address, b
a(1).pin);
End if;
--note: table t2 is also of the same structure of object t1;
End;
Here my code is giving an error as reference to uninitialised collection. But as you can see, i have initialised the collection in declaration itself.
Kindly help me on this.
Here's how.
Sample tables:
t2is empty, but has the same structure astable1:Types:
Procedure (note differences; you don't have to initialize nor extend anything. Also, in your code, you're populating
tebut never returned anything becauseoutparameter's name isp1, notte):Testing:
t2table's contents: