存储过程返回数组对象例子
2013-07-30 18:58
295 查看
其实就相当于返回List里面放的对象数据,定义如下
1.创建存储过程对象
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH"
as object(
ACCOUNT_ID NUMBER,
INIT_AMOUNT NUMBER,
DEBIT_AMOUNT NUMBER,
CREDIT_AMOUNT NUMBER
)
2.创建存数过程数组
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH_TABLE"
as table of t_account_month
3.创建存储过程
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.创建存储过程对象
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH"
as object(
ACCOUNT_ID NUMBER,
INIT_AMOUNT NUMBER,
DEBIT_AMOUNT NUMBER,
CREDIT_AMOUNT NUMBER
)
2.创建存数过程数组
CREATE OR REPLACE TYPE "T_ACCOUNT_MONTH_TABLE"
as table of t_account_month
3.创建存储过程
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;
相关文章推荐
- ORACLE ADF11g: AM 代码返回存储过程数据库对象数组
- Java调用存储过程(返回:简单类型、自定义对象、列表数组)
- 初步的学会用数组动态添加参数(一个添加存储过程参数的例子)
- DELPHI 调用 Oracle 存储过程并返回数据集的例子.
- IBatis调用ORACLE的存储过程、函数的返回结果集例子
- 存储过程返回结果转化为对象属性值的方法-bboss persistent o/r mapping机制应用
- C#中的类SqlCommand对象使用方法ExecuteNonQuery()调用SQLServer存储过程时,存储过程执行成功,数据发生改变,但是返回-1
- Oracle存储过程例子:运用了正则表达式、数组等
- 最完整的:JAVA调用ORACLE的存储过程、函数的返回结果集例子
- JAVA调用ORACLE带数组输入参数和返回游标结果集的存储过程
- JAVA调用ORACLE的存储过程、函数的返回结果集例子
- ORACLE ADF11g:AM 存储过程传入数据库对象数组
- Delphi 调用 Oracle 存储过程并返回数据集的例子.
- Oracle存储过程例子:运用了正则表达式、数组等
- 最完整的:JAVA调用ORACLE的存储过程、函数的返回结果集例子
- 对返回数组的存储过程的处理
- 简化返回数据集的存储过程例子plsql调用
- Delphi 调用 Oracle 存储过程并返回数据集的例子
- 存储过程中使用RETURN语句返回数值,.Net里用ExecuteScalar方法结果将会导致一个未引用到具体对象的异常
- 基于C#中的类SqlCommand对象调用SQLServer存储过程时,存储过程执行成功,但是对象方法ExecuteNonQuery()返回-1