create or replace function pagesize(p_sql varchar2,pno number,pnosize number,pcount out number)
return sys_refcursor
as
v_sql varchar(2000);
ccount number;
tmpsql varchar2(2000);
cur_data sys_refcursor;
begin
v_sql:='select count(*) from ('||p_sql||') t';
tmpsql:='select * from (select rownum rowa,d.* from ('||p_sql||') d where rownum<='||pno*pnosize||') where rowa>'||(pno-1)*pnosize;
execute immediate v_sql into ccount;
pcount:=ceil(ccount/pnosize);
open cur_data for tmpsql;
return cur_data;
end;
这是一个分页的存储过程