Home > Database > Mysql Tutorial > Oracle数据库实现分页功能

Oracle数据库实现分页功能

WBOY
Release: 2016-06-07 14:57:22
Original
1748 people have browsed it

无详细内容 无 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 返回参数 --in 输入参数 --in out 返回参数 v_sql varchar2(200); v_where varchar2

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 返回参数
 --in 输入参数
 --in out  返回参数
  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);
  --执行sql语句
  open p_cursor for v_sql;
 end pro_page;
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template