oracle存储过程分页问题求解
今天自己写了一个测试的项目,研究了一下oracle存储过程分页的问题,闲话少说先看代码:
procedure getrows(
v_tablename varchar, --表名
stanum integer, --开始
endnum integer, --结束
x_cur out XCH_CURSOR --返回
)
as
v_sql varchar(200);
begin
v_sql:='select b.zgxm,c.dwmc,a.* from
(select b.* from (select a.*,rownum as rn from (select * from '|| v_tablename ||') a
where rownum<='|| endnum ||') b where rn>='|| stanum ||' ) a
left join h_grxx b on a.grzh=b.grzh
left join h_dwxx c on a.dwzh=c.dwzh' ;
open x_cur for v_sql;
end getrows;