Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

want to return nested table from anonymous block or function

2677606Mar 17 2016 — edited Mar 17 2016

1. If i declare record , then define nested table of record type  and then using bulk collect i can fetch data into nested table which is correct

Eg

declare

type abc_rec is record (f_name tbl_member_contact.first_name%type, l_name tbl_member_contact.last_name%type);

type nst is table of abc_rec ;

v_ret nst ;

cursor c1 is select first_name,last_name from tbl_contact where code='DD';

c_limit pls_integer :=20 ;

begin

open c1;

loop

fetch c1 BULK COLLECT into v_ret limit c_limit;

           EXIT WHEN v_ret.COUNT = 0;

end loop;

close c1;

end;

2. But If i declare object and use in anonymous block  and then using bulk collect , i am not able to get output  giving mismatch error .

Eg.

create type nested_type as object (first_name varchar2(100),last_name varchar2(200)) ;

create type  nested_type1 is table of nested_type;

declare

v_ret nested1_type;

cursor c1 is select first_name,last_name from tbl_contact where code='DD';

c_limit pls_integer :=20 ;

begin

open c1;

loop

fetch c1 BULK COLLECT into v_ret limit c_limit;

           EXIT WHEN v_ret.COUNT = 0;

end loop;

close c1;

end;

Thanks in Advance

Regards,

Aman

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2016
Added on Mar 17 2016
7 comments
1,534 views