create or replace package mypkg
as
cursor c is select
cast( owner as varchar2(30) ) as x1,
cast( object_name as varchar2(60) ) x2,
cast( created as date ) as x3
from all_objects
where rownum <=3 ;
type cur_tab is table of c%rowtype;
function foo return mypkg.cur_tab pipelined;
end;
Package created.
create or replace package body mypkg
as
function foo return mypkg.cur_tab pipelined
as
l_data cur_tab;
begin
open c;
fetch c bulk collect into l_data;
close c;
for i in 1..l_data.count
loop
pipe row( l_data(i) );
end loop;
return ;
end;
end;
Package Body created.
select * from table( mypkg.foo )
ATTR_1 | ATTR_2 | ATTR_3 |
---|---|---|
SYS | ALERT_TYPE | 16-FEB-18 |
SYS | ALL_ALL_TABLES | 16-FEB-18 |
SYS | ALL_COL_COMMENTS | 16-FEB-18 |