在看了眾多的分頁存儲過程以後發現都是針對sqlserver的
oracle分頁存儲過程的思路於sqlserver的思路是一樣的
存儲過程看上去有點不一樣
在oracle的存儲過程中返回記錄集
由於設想中把復雜的sql語句生成
以下是在oracle中實現的分頁存儲過程
create or replace package DotNet is
TYPE type_cur IS REF CURSOR;
PROCEDURE DotNetPagination(
Pindex in number
Psql in varchar
Psize in number
Pcount out number
v_cur out type_cur
);
procedure DotNetPageRecordsCount(
Psqlcount in varchar
Prcount out number
);
end DotNot;
create or replace package body DotNet is
PROCEDURE DotNetPagination(
Pindex in number
Psql in varchar
Psize in number
Pcount out number
v_cur out type_cur
)
AS
v_sql VARCHAR
v_count number;
v_Plow number;
v_Phei number;
Begin
v_sql :=
execute immediate v_sql into v_count;
Pcount := ceil(v_count/Psize);
v_Phei := Pindex * Psize + Psize;
v_Plow := v_Phei
v_sql :=
open v_cur for v_sql;
End DotNetPagination;
procedure DotNetPageRecordsCount(
Psqlcount in varchar
Prcount out number
)
as
v_sql varchar
v_prcount number;
begin
v_sql :=
execute immediate v_sql into v_prcount;
Prcount := v_prcount;
end DotNetPageRecordsCount;
end DotNot;
以下是中調用oracle分頁存儲過程的步驟
調用返回記錄集的存儲過程
自定義分頁功能
Protected WithEvents DataGrid
Dim conn As New OracleClient
Dim cmd As New OracleClient
Dim dr As OracleClient
Private Sub gridbind(ByVal pindex As Integer
conn
cmd
cmd
conn
cmd
cmd
cmd
cmd
Me
Me
Me
Me
cmd
cmd
cmd
cmd
cmd
cmd
cmd
dr = cmd
Me
Me
dr
conn
Response
End Sub
Private Sub Page_Load(ByVal sender As System
If Not Page
Dim psql As String =
gridbind(
End If
End Sub
Private Sub DataGrid
Dim psql As String =
Me
gridbind(e
End Sub
From:http://tw.wingwit.com/Article/program/Oracle/201311/17152.html