我想写一个分页的存储过程,接收页大小我第几页两个参数,请问怎么实现?
解决方案 »
- Error while registering Oracle JDBC Diagnosability MBean.
- 如何提高oracle排序速度
- oracle 菜鸟问题,按题给分。
- oracle:合并两个table
- 帮定变量的问题
- oracle 使用调查~
- 刚装好的oracle , 连不起,急。。。
- 很急的问题(在线)
- Oracle8.1.6怎样连接SQL SERVER2000 ?(在线等待)
- 为啥我的oracle数据库别人连不上,可别人能连上其它的oracle数据库,难道我的oracle服务器还要别的设定吗?
- oracle9i 10g 超过1000汉字问题
- 存储过程报ORA-01722无效数字错误
var ocursor refcursor;declare
ipagesize number;
ipagenum number;
istart number;
iend number;begin
ipagesize := 10; --每页10条记录
ipagenum := 2; --第二页 istart := ipagenum * ipagesize;
iend := istart + ipagesize - 1; open :ocursor for
select *
from (select t.*, rownum as rid from tabname t order by rowid)
where rid between istart and iend;
end;
/print ocursor;你根据这个改成存储过程吧
给个例子
create or replace procedure test_pro1(a in number,b in number)
as
date1 varchar2(10);
begin
for cur1 in (select days from(
select days,row_number()over(order by days)rn from test_b)
where rn>a*b and rn<=a*(b+1))
loop
date1:=to_char(cur1.days,'YYYY-MM-DD');
dbms_output.put_line(date1);
end loop;
end test_pro1;
create table test_b as select to_date(
'2009-08-05','yyyy-mm-dd')-1 + rownum days from dual
connect by rownum <=100;begin
test_pro1(10,3);
end;--output
2009-09-04
2009-09-05
2009-09-06
2009-09-07
2009-09-08
2009-09-09
2009-09-10
2009-09-11
2009-09-12
2009-09-13