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!

Table Out from a Function: Invalid Datatype error

sathya_mounikaMay 9 2013 — edited May 9 2013
Hi,

I am getting an ORA-00902: invalid datatype error when I am trying call the below function from a select statement. Here I am trying to get a table out from a function.
create or replace package pkg10
as

type tabletype1 is table of table1%rowtype
index by binary_integer;

function func1 return tabletype1;

end pkg10;
create or replace package body pkg10
as

function func1 return tabletype1 
is
    v_tab1 tabletype1;
    idx integer;
begin 

    idx := 1;
    
    for i in (select * from table1)
    loop
        v_tab1(idx).name1 := i.name1;
        v_tab1(idx).key := i.key;
        idx := idx+1;
        
    end loop;

return v_tab1; 

end func1; 

end pkg10;
select * from table(pkg10.func1);
Please point me out on where I am going wrong.

Thanks
This post has been answered by sb92075 on May 9 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 6 2013
Added on May 9 2013
2 comments
2,511 views