create or replace function text(
starttime in varchar2,
endtime in varchar2,
timetype in number,
spid in number,
pagesize in number,
currentpage in number,
datacount out number
)return white_list_type_array as
strsql varchar2(1000);
spinfos white_list_type_array;
rs sys_refcursor;
id number;
sp_name varchar2(200);
sp_code varchar2(200);
sp_status number;
sp_type number;
mdn_count number;
record whitlistcount;
pageinfo white_list_type_array;
i number;
a number;
currentsize number;
pattern varchar2(20);
psize number;
begin
---初始化引數
i := 1;
spinfos := white_list_type_array();
if timetype = 0 then
pattern := 'yyyy-mm-dd';
else
pattern := 'yyyy_mm';
end if;
------------------------獲取資料開始-----------------------------
-- 或許企業編號、 名稱、 id
strsql := 'select id, sp_code, sp_name ,sp_type ,sp_status from nm_sp_info where id != 0 ';
if spid > 0 then
strsql := strsql || ' and id ='||spid ;
end if;
open rs for strsql;
loop
fetch rs
into id, sp_name, sp_code,sp_type ,sp_status;
exit when rs%notfound;
strsql := 'select count(mdn) from nm_net_user_' || id || ' where 1=1 ';
if starttime is not null then
strsql := strsql || ' and to_char(modify_time,''' || pattern ||
''') >= ''' || starttime || '''';
end if;
if starttime is not null then
strsql := strsql || ' and to_char(modify_time,''' || pattern ||
''') <= ''' || endtime || '''';
end if;
execute immediate strsql into mdn_count;
spinfos.extend;
record := whitlistcount(id, sp_name, sp_code,sp_type,sp_status,mdn_count);
spinfos(i) := record;
i := i + 1;
end loop;
close rs ;
datacount := spinfos.count;
---分頁開始
i := i -1;
if currentpage < 1 then
return null;
end if;
if currentpage < 2 then
currentsize := 1;
else
currentsize := (currentpage - 1) * pagesize;
currentsize := currentsize + 1;
end if;
if i < currentsize then
return null;
end if;
if i = pagesize then
psize := pagesize;
else
if i < currentsize + pagesize then
psize := mod(i, pagesize);
end if;
end if;
if psize is null then
psize := pagesize;
end if;
a := 1;
i := 1;
pageinfo := white_list_type_array();
pageinfo.extend(psize);
for i in currentsize..psize + currentsize - 1 loop
pageinfo(a) := spinfos(i);
a := a + 1;
end loop;
---分頁結束
return pageinfo;
end text;
/乙個自定義的陣列,分別記錄了動態表資料,還有一張資料表中的資料 ,新增分頁功能, 還有不足之處請大家多多指教
乙個oracle函式返回陣列的例子
create or replace type t ret table is table of varchar2 20 create or replace function f test var num in integer return t ret table is var out t ret ta...
函式返回乙個SqlDataReader物件
解決方法 1.嘗試使用dataset 2.執行資料庫操作命令 sqldatareader reader mysqlcommand.executereader commandbeh ior.closeconnection 示例 原 獲取書的目錄 public sqldatareader getbook...
乙個簡單的oracle函式返回陣列的例子 zz
乙個簡單的oracle函式返回陣列的例子 zz create or replace type t ret table is table of varchar2 20 create or replace function f test var num in integer return t ret t...