CREATE OR REPLACE PACKAGE BODY "P_PAGE" is
Procedure Per_QuickPage
(
TbName in varchar2, --表 名
FieldStr in varchar2, --欄位集
RowFilter in varchar2, --過濾條件
SortStr in varchar2, --排序集
PageSize in number, --分頁大小
PageIndex in number, --頁碼
TotalCount out number, --總記錄數
Cur_ReturnCur out T_CURSOR
)
is
v_SourceTb1 varchar2(32000); --動態表名1
v_SourceTb2 varchar2(32000); --動態表名2
v_SourceTb3 varchar2(32000); --動態表名3
v_SourceTb4 varchar2(32000); --動態表名4
v_TotalCount varchar2(50); --總記錄數
v_sql varchar2(32000); --動態sql
MaxRowNum number;
MinRowNum number;
begin
if (PageIndex=0) then
MinRowNum := 0;
else
MinRowNum := (PageIndex-1)*PageSize;
end if;
MaxRowNum := MinRowNum+PageSize;
v_SourceTb1 := '(select '|| FieldStr ||' from '|| TbName ||') SourceTb1';
v_SourceTb2 := '(select * from '|| v_SourceTb1 ||' where '|| RowFilter ||' '|| SortStr ||') SourceTb2';
v_SourceTb3 := '(select rownum as RowIndex,SourceTb2.* from '|| v_SourceTb2 ||' ) SourceTb3';
v_SourceTb4 := '(select * from '|| v_SourceTb1 ||' where '|| RowFilter ||') SourceTb4';
v_sql := 'select count(*) as TotalCount from '|| v_SourceTb4;
execute immediate v_sql into v_TotalCount;
TotalCount := v_TotalCount;
v_sql := 'select * from '|| v_SourceTb3 ||' where RowIndex >'|| MinRowNum ||' And RowIndex<='|| MaxRowNum;
open Cur_ReturnCur for v_sql;
end Per_QuickPage;
END P_page;
===============================
create or replace package P_page is
TYPE T_CURSOR IS REF CURSOR;
Procedure Per_QuickPage
(
TbName in varchar2, --表 名
FieldStr in varchar2, --欄位集
RowFilter in varchar2, --過濾條件
SortStr in varchar2, --排序集
PageSize in number, --分頁大小
PageIndex in number, --頁碼
TotalCount out number, --總記錄數
Cur_ReturnCur out T_CURSOR
);
end P_page;