存儲過程返回數(shù)組對象示例代碼
更新時間:2013年07月31日 11:51:55 作者:
存儲過程返回數(shù)組對象其實就相當于返回List里面放的對象數(shù)據(jù),下面與大家分享是例子,感興趣的朋友可以學習下
其實就相當于返回List里面放的對象數(shù)據(jù),定義如下
1.創(chuàng)建存儲過程對象
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH"
as object(
ACCOUNT_ID NUMBER,
INIT_AMOUNT NUMBER,
DEBIT_AMOUNT NUMBER,
CREDIT_AMOUNT NUMBER
)
2.創(chuàng)建存數(shù)過程數(shù)組
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH_TABLE"
as table of t_account_month
3.創(chuàng)建存儲過程
create or replace function account_month(tDate IN DATE)
return t_account_month_table pipelined
as
v_account_month t_account_month;
v_date DATE;
begin
v_date:=tDate;
IF v_date IS NULL THEN
v_date:=sysdate;
END IF;
for myrow in (
select d.ACCOUNT_ID,
sum(decode(sign(d.create_time-trunc(v_date,'month')),-1,
d.debit_unvoucher + d.debit_unposted +d.debit_posted - d.CREDIT_UNVOUCHER -d.CREDIT_UNPOSTED- d.CREDIT_POSTED_D,
0)) INIT_AMOUNT,
sum(decode(sign(trunc(d.create_time,'year')-trunc(sysdate,'year')),0,
d.debit_unposted+d.debit_posted,
0)) DEBIT_AMOUNT,
sum(decode(sign(trunc(d.create_time,'year')-trunc(sysdate,'year')),0,
d.credit_unposted+d.credit_posted,
0)) CREDIT_AMOUNT
from ACCOUNT_DAILY_VEIW d
group by d.ACCOUNT_ID
) loop
v_account_month := t_account_month(
myrow.ACCOUNT_ID,
myrow.INIT_AMOUNT,
myrow.DEBIT_AMOUNT,
myrow.CREDIT_AMOUNT
);
pipe row (v_account_month);
end loop;
return;
end;
1.創(chuàng)建存儲過程對象
復制代碼 代碼如下:
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH"
as object(
ACCOUNT_ID NUMBER,
INIT_AMOUNT NUMBER,
DEBIT_AMOUNT NUMBER,
CREDIT_AMOUNT NUMBER
)
2.創(chuàng)建存數(shù)過程數(shù)組
復制代碼 代碼如下:
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH_TABLE"
as table of t_account_month
3.創(chuàng)建存儲過程
復制代碼 代碼如下:
create or replace function account_month(tDate IN DATE)
return t_account_month_table pipelined
as
v_account_month t_account_month;
v_date DATE;
begin
v_date:=tDate;
IF v_date IS NULL THEN
v_date:=sysdate;
END IF;
for myrow in (
select d.ACCOUNT_ID,
sum(decode(sign(d.create_time-trunc(v_date,'month')),-1,
d.debit_unvoucher + d.debit_unposted +d.debit_posted - d.CREDIT_UNVOUCHER -d.CREDIT_UNPOSTED- d.CREDIT_POSTED_D,
0)) INIT_AMOUNT,
sum(decode(sign(trunc(d.create_time,'year')-trunc(sysdate,'year')),0,
d.debit_unposted+d.debit_posted,
0)) DEBIT_AMOUNT,
sum(decode(sign(trunc(d.create_time,'year')-trunc(sysdate,'year')),0,
d.credit_unposted+d.credit_posted,
0)) CREDIT_AMOUNT
from ACCOUNT_DAILY_VEIW d
group by d.ACCOUNT_ID
) loop
v_account_month := t_account_month(
myrow.ACCOUNT_ID,
myrow.INIT_AMOUNT,
myrow.DEBIT_AMOUNT,
myrow.CREDIT_AMOUNT
);
pipe row (v_account_month);
end loop;
return;
end;
相關文章
免費開源數(shù)據(jù)庫:SQLite、MySQL和PostgreSQL的優(yōu)缺點
對于處理大規(guī)模數(shù)據(jù)和高并發(fā)訪問的場景,MySQL和PostgreSQL更適合,SQLite在小型應用程序或嵌入式設備中是一種輕量級、簡單和易于使用的選擇,根據(jù)具體的應用需求和場景特點,選擇合適的開源關系型數(shù)據(jù)庫可以提供更好的性能、可擴展性和靈活性2024-02-02使用 Navicat 創(chuàng)建數(shù)據(jù)庫并用JDBC連接的操作方法
這篇文章主要介紹了使用 Navicat 創(chuàng)建數(shù)據(jù)庫并用JDBC連接的操作方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-11-11數(shù)據(jù)庫 SQL千萬級數(shù)據(jù)規(guī)模處理概要
我在前年遇到過過億條的數(shù)據(jù)。以至于一個處理過程要幾個小時的。后面慢慢優(yōu)化,查找一些經(jīng)驗文章。才學到了一些基本方法。綜合敘之,與君探討之。2009-07-07IndexedDB瀏覽器內(nèi)建數(shù)據(jù)庫并行更新問題詳解
這篇文章主要為大家介紹了IndexedDB瀏覽器內(nèi)建數(shù)據(jù)庫并行更新問題詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-12-12