/**page slide procedure
*author:robert.c
*time:2006.11.17
*/create or replace procedure tablepage_select(v_page_size int, --the size of a page of list
v_current_page int, --the current page of list
v_table_name varchar2,
--v_sql_select varchar2, --the select sql for procedure
--v_sql_count varchar2, --the count sql for procedure
--v_out_recordcount out int, --the num of return rows
p_cursor out refcursor_pkg.return_cursor) as
v_sql varchar2(3000); --the sql for select all rows of list
v_sql_count varchar2(3000); --the count sql for procedure
v_count int; -- the amount rows fo original list
v_endrownum int; --the end row num of the current page
v_startrownum int; --the start row num of the current page
begin
----catch the amount rows of list
v_sql_count:='select count(rownum) from '||v_table_name;
execute immediate v_sql_count
into v_count;
-- v_out_recordcount := v_count;
----set the value of start and end row
v_endrownum := v_current_page * v_page_size;
v_startrownum := v_endrownum - v_page_size + 1;
----the sql for page slide
v_sql := 'select * from (select '||v_table_name||'.*, rownum rn from '||v_table_name||' where rownum <= ' ||
to_char(v_endrownum) || ') where rn >= ' ||
to_char(v_startrownum);
open p_cursor for v_sql;
end tablepage_select;
Oracle分頁儲存過程
第一步要先建立包 create or replace package pkg query is type cur query is ref cursor procedure met down query m tablename in varchar2,表名 m strwhere in varchar...
Oracle分頁儲存過程
第一步要先建立包 create or replace package pkg query is type cur query is ref cursor procedure met down query m tablename in varchar2,表名 m strwhere in varchar...
Oracle分頁儲存過程
create or replace package jt p page is type type cur is ref cursor 定義游標變數用於返回記錄集 procedure pagination pindex in number,要顯示的頁數索引,從0開始 psql in varchar2,...