oracle集群存储过程慢,存储过程执行速度很慢~怎么解决?

create or replace procedure prc_yanglaolixi is

str_aac001 varchar2(16);

str2_aac001 varchar2(16);

num_aic410 number(12,2);

num_aic412 number(12,2);

num_aic413 number(12,2);

str_aae045 varchar2(6);

interest_year number;

sum_money number(12,2);

total_money number(12,2);

cur_time varchar2(50);

CURSOR CUR_AAC001  IS

SELECT DISTINCT AAC001 FROM IC40 ;

cursor cur_lixi is

select aac001,aae045,aic410,aic412,aic413 from ic40 where aac001=str_aac001;

begin

--删除数据

execute immediate 'truncate table v1_yanglao_zhye';

cur_time:=to_char(sysdate,'yyyymm');

open cur_aac001;

loop

fetch cur_aac001 into str_aac001;

-- sum_money:=0;

total_money:=0;

exit when CUR_AAC001%notfound;

open cur_lixi;

loop

fetch cur_lixi into str2_aac001,str_aae045,num_aic410,num_aic412,num_aic413; --日期类型错误?

exit when cur_lixi%notfound;

sum_money:=num_aic410+num_aic412+num_aic413;

while to_date(str_aae045,'yyyymm')

loop

select aia001 into interest_year from aa03

where aae001=case

when to_number(substr(str_aae045,1,4))>=7 then to_number(substr(str_aae045,1,4))

else to_number(substr(str_aae045,1,4))-1 end;

sum_money:=sum_money*(1+interest_year/12);

str_aae045:=to_char(add_months(to_date(str_aae045,'yyyymm'),1),'yyyymm');

end loop;

total_money:=total_money+sum_money;

end loop;

close cur_lixi;

insert into v1_yanglao_zhye select t2.AAC001 ,t2.AAB001 ,t2.AAC003 ,t2.aac004 ,t2.akc020 ,t2.AAC002 ,

total_money ,count(aae003)  ,max(aae003)  from ic40 t1,ac01 t2 where t2.AAC001=t1.aac001

and t2.aac001=str_aac001

group by t2.AAC001,t2.AAC003,t2.aac004,t2.AAB001,t2.akc020,t2.AAC002 ;

commit;

end loop;

close CUR_AAC001;

--aa03.aia001养老记账利率

end prc_yanglaolixi;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值