1、建立package
create2、建立儲存過程;裡面用到了父子級聯查詢;sql中如果用到了單引號,需要再用乙個單引號轉義orreplace package forpaged is
type my_csr
is ref cursor
;
procedure getpaged(tablename in
varchar2,objectid in
number,fields in
varchar2,wherecase in
varchar2,orderfieldstr varchar2,pagesize in
number,pageindex in
number,expression varchar2,totalcount out number
,csr out forpaged.my_csr);
end forpaged;
create3、asp.net中使用orreplace
procedure getpaged(tablename in
varchar2,objectid in
number,fields in
varchar2,wherecase in
varchar2,orderfieldstr in
varchar2,pagesize in
number,pageindex in
number,expression varchar2,totalcount out number,csr out forpaged.my_csr) is
v_sql
varchar2(1000
); v_begin
number:=(pageindex-
1)*pagesize+
1; --
開始記錄
v_end number:=pageindex*pagesize; --
結束記錄
begin
v_sql:='
select count(*) from (select entitycode from
'|| tablename ||
'where
'|| wherecase||
'and exists(select distinct companycode from company where
'||tablename||
'.entitycode=company.companycode start with object_id=
'||objectid||
'connect by prior object_id=parent_id)) t';
execute immediate v_sql into
totalcount;
if expression is
notnull
then
v_sql:='
select
'|| fields ||',
'||expression||
'heji from
(select t.* ,rownum rn from (select
'|| fields ||
'from
'|| tablename||
'where
'|| wherecase ||
'and exists(select distinct companycode from company where
'||tablename||
'.entitycode=company.companycode start with object_id=
'||objectid||
'connect by prior object_id=parent_id) order by
'|| orderfieldstr ||
') t)
where rn>=
'|| v_begin||
'and rn<='||
v_end;
else
v_sql:='
select
'|| fields ||
'from
(select t.* ,rownum rn from (select
'|| fields ||
'from
'|| tablename||
'where
'|| wherecase ||
'and exists(select distinct companycode from company where
'||tablename||
'.entitycode=company.companycode start with object_id=
'||objectid||
'connect by prior object_id=parent_id) order by
'|| orderfieldstr ||
') t)
where rn>=
'|| v_begin||
'and rn<='||
v_end;
endif
;
open csr for
v_sql;
--close csr;關閉後則不會傳出資料集
end getpaged;
1業務邏輯層///2
///使用儲存過程實現的分頁查詢
3///
4///
資料表5
///實體表主鍵
6///
表中字段拼接的字串
7///
查詢條件
8///
每頁顯示資料行數
9///
當前頁10
///排序字段拼接的字串
11///
符合條件總記錄數
12///
計算表示式
13///
14public datatable getreportdatabypage(m_selectdata model, out
inttotalcount)
15
1資料操作層///2
///分頁儲存過程
3///
4///
儲存過程名字
5///
tablename表名,fields查詢字段字串,wherecase查詢條件,orderfieldstr排序字段字串,pagesize每頁顯示資料行數,pageindex頁碼,totalcount總記錄數,傳出,csr游標,傳出
6///
7public
static datatable excuteprocedure(string
proname, oracleparameter parameters)
818 comm.commandtype =commandtype.storedprocedure;
19conn.open();
20 oracledataadapter oda = new
oracledataadapter(comm);
21 dataset ds = new
dataset();
22oda.fill(ds);
23//
得到查詢結果表
24 table = ds.tables[0
];25}26
}27return
table;
28 }
oracle資料分頁
建立分頁過程 create or replace procedure fenye v tablename in varchar2,表名 v pagesize in number,每頁顯示的記錄數 v pagenum in number,當前頁碼 v countrows out number,總記錄數...
SpringMVC 響應資料傳出
springmvc除過在方法上傳入原生的request和session外還能怎麼樣把資料帶給頁面?1 可以在方法處傳入map 或者model或者modelmap。給這些引數裡面儲存的所有資料都會放在請求域中。可以在頁面獲取 關係 map,model,modelmap 最終都是bindingaware...
ORACLE資料庫分頁
create proc p show querystr nvarchar 4000 表名 檢視名 查詢語句 pagesize int 10,每頁的大小 行數 pagecurrent int 1,要顯示的頁 fdshow nvarchar 4000 要顯示的字段列表,如果查詢結果有標識字段,需要指定此...