function f_add_procedure_log(
pname in varchar2,
pstatus in varchar2,
beginTime in date,
endTime in date,
remark in varchar2)
return number
as
begin
insert into t_procedure_log(NAME,STATUS,begin_time,end_time,remark)values(pname,pstatus,beginTime,endTime,remark);
commit;
return 1;
end f_add_procedure_log;
procedure P_BATCH_DEBT_SUB_STOP as
itype varchar(1):='3';
maxmoney number:=144;
beginTime date;
endTime date;
custbalance number;
numindex number :=0;
pname varchar(2) :='欠费停机存储过程';
remark varchar(2);
rs number;
cursor accountacursor is select acc.cust_no as cust_no,sum(acc.money) as money from T_ACCOUNT acc where acc.accstatus=1 group by acc.cust_no;
begin
beginTime :=sysdate;
execute immediate 'delete from CA_CJTJGD_SUBSCRIBER where type = 3';
for mycursor in accountacursor
loop
select sum(accbook.balance) into custbalance from T_ACBOOKTYPE actype,T_ACCUSTACCBOOK accbook
where actype.specialaccbook='1' and actype.acctypeid = accbook.acctypeid and accbook.cust_no = mycursor.cust_no
group by accbook.cust_no;
if (mycursor.money-custbalance) > maxmoney then
insert into CA_CJTJGD_SUBSCRIBER(subscriberid,type,status)
select sub.subscriberid,itype,1 from T_SUBSCRIBER sub,T_CSCUSTOMER cus
where sub.status='1'
and sub.MAINFLAG='1'
and sub.cust_no=cus.cust_no
and cus.cust_no=mycursor.cust_no
and trunc(add_months(sub.createtime,36)-1)<=trunc(sysdate);
end if;
end loop;
endTime :=sysdate;
remark := '成功';
A:pack_subowe.f_add_procedure_log(pname,1,beginTime,endTime,remark);
B:rs := pack_subowe.f_add_procedure_log(pname,1,beginTime,endTime,remark);
commit;
exception
when others then
rollback;
end P_BATCH_DEBT_SUB_STOP;
A:直接调用pack_subowe.f_add_procedure_log会报错:报错PLS-00221: 'function' 不是过程或尚未定义。原因是原因是在调用函数时没有接收返回值
B:情况下是不会报错
Compilation errors for PACKAGE BODY XMTEST.PACK_SUBOWE
Error: PLS-00221: 'F_ADD_PROCEDURE_LOG' 不是过程或尚未定义
Line: 51
Text: pack_subowe.f_add_procedure_log(pname,1,beginTime,endTime,remark);
Error: PL/SQL: Statement ignored
Line: 51
Text: pack_subowe.f_add_procedure_log(pname,1,beginTime,endTime,remark);
Error: PLS-00221: 'F_ADD_PROCEDURE_LOG' 不是过程或尚未定义
Line: 57
Text: pack_subowe.f_add_procedure_log(pname,2,beginTime,endTime,remark);
Error: PL/SQL: Statement ignored
Line: 57
Text: pack_subowe.f_add_procedure_log(pname,2,beginTime,endTime,remark);