oracle存儲過程分頁代碼是怎麼實現的
/*******存儲過程分頁代碼**********/
create or replace package pck_my is
type c_my is ref cursor;
procedure page_moed(
v_table in varchar
current_page in out number
pageSize in out number
total out number
countPage out number
c_cursor out pck_my
);
end pck_my;
create or replace package body pck_my as
procedure page_moed(
v_table in varchar
current_page in out number
pageSize in out number
total out number
countPage out number
c_cursor out pck_my
)is
v_sql varchar
v_max number;
v_min number;
e_table exception;
begin
if v_table is null then
raise e_table;
end if;
if current_page is null then
current_page:=
end if;
if pageSize<=
pageSize:=
end if;
v_max:=(current_page+
v_min:=current_page*pageSize;
v_sql:=
from (select filminfo
where t >
open c_cursor for v_sql;
v_sql:=
execute immediate v_sql into total;
if mod(total
countPage:=total/pageSize;
else
countPage:=total/pageSize+
end if;
exception
when e_table then
dbms_output
end;
end pck_my;
select * from filminfo
java測試代碼
[html]
package com
import java
import java
import java
import java
import java
public class Pckage {
/**
* @param args
*/
public static void main(String[] args) {
Connection con;
ResultSet rs;
CallableStatement cs;
try {
Class
con=DriverManager
String sql=
cs=con
//指定類型
/* v_table in varchar
current_page in out number
pageSize in out number
total out number
countPage out number
c_cursor out pck_my
*/
//cs
cs
cs
cs
cs
cs
cs
cs
int total=cs
int countPage=cs
rs=(ResultSet)cs
System
System
while(rs
System
}
} catch (ClassNotFoundException e) {
// TODO Auto
e
} catch (SQLException e) {
// TODO Auto
e
}
}
}
From:http://tw.wingwit.com/Article/program/Oracle/201311/17872.html