oracle 存储过程循环插入数据不定时出现卡死,求高手指点,循环过程如下:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 存储过程循环插入数据不定时出现卡死,求高手指点,循环过程如下:相关的知识,希望对你有一定的参考价值。

WHILE to_char(v_looptime,'yyyy-MM-dd') <= v_loopenddate
LOOP
--- 日发生额
v_eyerydate := to_char(v_looptime,'yyyy-MM-dd');
insert into gl_dailybalancetemp(creditamount,creditquantity,debitamount,debitquantity,fraccreditamount,fracdebitamount,localcreditamount,localdebitamount,pk_accchart,pk_accasoa,pk_accountingbook,deverydate,year,period,pk_currtype)
select tempb.creditamount,tempb.creditquantity,tempb.debitamount,tempb.debitquantity,
tempb.fraccreditamount,tempb.fracdebitamount,tempb.localcreditamount,tempb.localdebitamount,
tempb.pk_accchart,tempb.pk_accasoa,tempb.pk_accountingbook,tempb.eyerydate,tempb.year,tempb.period,tempb.pk_currtype
from
(
select pk_accountingbook,pk_accchart,pk_accasoa from gl_dailybalancevoucher where deverydate<= '' || v_eyerydate || ''
group by pk_accountingbook,pk_accchart,pk_accasoa
) tempa
inner join
(
select sum(b.creditamount) creditamount,sum(b.creditquantity) creditquantity,sum(b.debitamount) debitamount,sum(b.debitquantity) debitquantity,
sum(b.fraccreditamount) fraccreditamount,sum(b.fracdebitamount) fracdebitamount,sum(b.localcreditamount) localcreditamount,sum(b.localdebitamount) localdebitamount,
b.pk_accchart,b.pk_accasoa,a.pk_accountingbook,v_eyerydate eyerydate,substr(min(a.year|| '-' ||a.period),0,4) year,substr(min(a.year|| '-' ||a.period),6,2) period,max(b.pk_currtype) pk_currtype
from gl_voucher a inner join gl_detail b on a.pk_voucher=b.pk_voucher
where nvl(a.dr,0)=0 and nvl(b.dr,0)=0 and a.year !='0000' and a.period !='00' and a.prepareddate >= ''|| v_startdate||'' and a.prepareddate<= ''|| v_eyerydate||''
and a.pk_accountingbook in(select pk_accountingbook from gl_dailybalancevoucher where substr(deverydate,0,4)=''|| v_startyear || '')
and b.pk_accasoa in(select pk_accasoa from gl_dailybalancevoucher where substr(deverydate,0,4)=''|| v_startyear || '')
group by a.pk_accountingbook,b.pk_accchart,b.pk_accasoa
)tempb on tempa.pk_accountingbook=tempb.pk_accountingbook and tempa.pk_accasoa=tempb.pk_accasoa;
commit;

v_looptime := v_looptime+1;
END LOOP;
按照日循环,原表数据稳定,没变化,但是偶尔循环能执行过去,大部分情况下就不定时的卡到哪个日期过不去。

参考技术A 感觉对日期的处理问题,你将日期类型转换为字符串类型再比较,这里不建议转,直接比较吧。

以上是关于oracle 存储过程循环插入数据不定时出现卡死,求高手指点,循环过程如下:的主要内容,如果未能解决你的问题,请参考以下文章

解决MYSQL库or表进行删除等操作时出现卡死等情况

JDBC处理大结果集

oracle中“ORA-00060: 等待资源时检测到死锁” 或存储过程编译卡死 解决方法

oracle存储过程中循环插入数据

用oracle存储过程将一张表的数据查出插入另一张表

oracle存储过程循环插数据