Oracle數(shù)據(jù)庫分頁功能的實(shí)現(xiàn),具體代碼如下:
create or replace procedure pro_page(table_name in varchar2,page in number,line in number,in_where in varchar2,p_cursor out sys_refcursor)
as
--out 返回參數(shù)
--in 輸入?yún)?shù)
--in out 返回參數(shù)
v_sql varchar2(200);
v_where varchar2(200);
begin
---判斷條件
if length(in_where) = 0 or in_where is null then
v_where := '1=1';
else
v_where := in_where;
end if;
--獲得sql語句
v_sql:='select * from( select t1.*,rownum num from '||t_name||' t1 where rownum<= ' ||(page*line)||' and '||v_where
||') where num >= ' || ((page-1)*line);
--執(zhí)行sql語句
open p_cursor for v_sql;
end pro_page;
更多信息請查看IT技術(shù)專欄