如何返回指定行数之间的
查询结果 以实现web记录分页 在Oracle中有许多的
方法 这里仅仅列出了 种 希望能对大家有所帮助 大家可以根据不同需要选择下面的script )select where rownum < 50 minus select where rownum < 30 这个方法因为用到了minus *** 作符,所以速度会受影响。 2) SELECT results FROM ( SELECT t2, rownum rownumber FROM ( SELECT t FROM mv_table t WHERE ORDER BY col1) t2) results WHERE resultsrownumber BEEEN 30 and 50 ORDER BY col1 这个方法是从一个论坛上看到的,没有亲自测试过 3) 定义cursor x, 2fetch x a,b,c; loop end loop; 其中用两个循环变量和一个FLAG变量,分别表示,当前的记录数,属于第几页的, 及第一页面。WINGwit ps; j:=to_number(kafyf); i:=1; open cx; loop fetch cx into col1,col2,col3,col4,col5,col6; if cx%NOTFOUND then exit; end if; if i>=j then htptableRowOpen; htptableData(col1); htptableData(col2); htptableData(col4); htptableData(col5); htptableData(col6); htptableData(col3); htptableRowClose; i:=i+1; if i=j+10 then l:=1; exit; end if; else i:=i+1; end if; end loop; close x; 该方法是名叫‘淼’的网友写的script,他用到了Oracle web2kit中的OWA_UTIL package。 4)How can one page forward and backwards through a table Externalize ROWNUM by implementing queries like this: SELECT FROM (SELECT ROWNUM rnum, FROM ) WHERE rnum BEEEN :low AND :high AND rownum <(:high :low + 1); where :low and :high are dynamically generated values depending on which result page the user is viewing Typically, they are used to show "Next 15 matches", "Previous 15 matches" links at the bottom of each page lishixinzhi/Article/program/Oracle/201311/17917
按照你现有的表创建历史数据:
create table khqfbd_1
(khn int,
khqxh int,
khmc varchar2(20),
qsrq varchar2(8),
jsrq varchar2(8),
bz varchar2(100));
insert into khqfbd_1 values (2024,1,'
第一季度','20240101','20240331','1');
insert into khqfbd_1 values (2024,2,'第二季度','20240401','20240630','1');
insert into khqfbd_1 values (2024,3,'第三季度','20240701','20240930','1');
insert into khqfbd_1 values (2024,4,'第四季度','20241001','20241231','1');
commit;
执行:
declare
v_year int;
begin
select max(khn) into v_year from khqfbd_1;
insert into khqfbd_1
values
(v_year+1, 1, '第一季度', v_year+1 || '0101', v_year+1 || '0331', '1');
insert into khqfbd_1
values
(v_year+1, 2, '第二季度', v_year+1 || '0401', v_year+1 || '0630', '1');
insert into khqfbd_1
values
(v_year+1, 3, '第三季度', v_year+1 || '0701', v_year+1 || '0930', '1');
insert into khqfbd_1
values
(v_year+1, 4, '第四季度', v_year+1 || '1001', v_year+1 || '1231', '1');
commit;
end;
执行后结果:
评论列表(0条)