犀利的存储过程 用来实现分页
create or replace procedure pageinfo
(v_sql varchar2,curpage number,pageunit number,ordercolumn varchar2,ordertype varchar2,rs out itfuture.r_cursor,v_count out number)
as
begin
--存储过程调用存储过程
--page(v_sql,curpage,pageunit,ordercolumn,ordertype,rs);
--querycount(v_sql,v_count);
--存储过程调用函数
v_count:=countrecord(v_sql);
rs:=pageByFun(v_sql,curpage,pageunit,ordercolumn,ordertype);
end;
create or replace procedure page
(v_sql varchar2,curpage number,pageunit number,ordercolumn varchar2,ordertype varchar2,rs out itfuture.r_cursor)
as
all_sql varchar2(200);
startpos number;
endpos number;
begin
if(curpage is not null) then
if(pageunit is not null)then
startpos:=(curpage-1)*pageunit;
endpos:=curpage*pageunit;
end if;
end if;
all_sql:=v_sql;
if(ordercolumn is not null) then
all_sql:=all_sql||' order by '||ordercolumn;
if(ordertype is not null and ordertype in('desc','asc'))then
all_sql:=all_sql||' '||ordertype;
end if;
end if;
all_sql:='select t2.* from (select t1.*,rownum r_id from ('||all_sql||') t1 where rownum<='||endpos||') t2 where t2.r_id>='||startpos;
open rs for all_sql;
exception ---扑捉异常
when others then
dbms_output.put_line('查询出错!');
raise;---把异常继续抛出
end;
---函数
create or replace function getValue(i number,j number) return number
as
m number;
begin
m:=i+j;
return m;
end;
create