create or replace package my_package as
type my_table is record(
id_ varchar2(45),
name_ varchar2(45),
update_time date,
sys_id varchar2(45)
);
type my_type is table of my_table;
function get_table(time_ date) return my_type pipelined;
end my_package; 3)创建包体(Packages bodies)
create or replace package body my_package as
function get_table(time_ date) return my_type
pipelined is
row_t my_table;
begin
for row_t in (select b.*
from (select id_, max(sys_id) maxsysid
from table1
where update_time < trunc(time_, 'month')
group by id_) a,
table1 b
where b.sys_id = a.maxsysid) loop
pipe row(row_t);
end loop;
return;
end;
end my_package; 4)PL/SQL调用此函数
select * from table(my_package.get_table(to_date('2014-12-31 10:34:12','yyyy-MM-dd hh24:mi:ss')));
运行结果: