create or replace package testpackage as
type test_cursor is ref cursor;
end testpackage;
create or replace procedure fenye(
tableName in varchar2,
pageSize in number,
pageNow in number,
myRowCount out number,
myPageCount out number,
p_cursor out testpackage.test_cursor) is
v_sql varchar2(1000);
v_begin number:=(pageNow -1)*pageSize+1;
v_end number:= pageNow*pageSize;
begin
v_sql := 'select * from (select t.*, rownum rn from (select * from '||tableName ||') t where rownum<='||v_end||') where rn>='||v_begin;
open p_cursor for v_sql;
v_sql := 'select count(*) from '||tableName;
execute immediate v_sql into myRowCount;
if mod(myRowCount,pageSize) = 0 then
myPageCount:= myRowCount/pageSize;
else
myPageCount:= myRowCount/pageSize+1;
end if;
--close p_cursor;
end;
/
标签:存储,分页,pageSize,number,cursor,sql,oracle,myRowCount,select
From: https://blog.51cto.com/u_13538361/6410380