不能在手动或分布事务方式下创建新的连接
在PB中执行如下SQL,提示:不能在手动或分布事务方式下创建新的连接!
我的语句:
declare cur_1 cursor for
select cus_code,pay_date from customer ;
open cur_1;
fetch cur_1 into :cuscode1,:date_1;
do while sqlca.sqlcode=0
......
tot_total1 = 0
select sum(total) into :tot_total1 from invoice where cus_code=:cuscode1 and date_build>:date_2 and date_build<=:date_3 ;
......
fetch cur_1 into :cuscode1,:date_1;
loop
close cur_1;
得到的tot_total1 为 0,即select sum(total) into :tot_total1 from invoice...这句没执行!
按照这个错误信息查了一下,好像用SELECT时,和Cursor有关。
有人说:是你CURSOR没有关闭,然后又继续SELECT导致的,你可以先把SELECT的结果扔到数组里,关了CURSOR再循环再SELECT。
但我的数据要在CURSOR里再用SELECT得到合计数!不能关了CURSOR再循环再SELECT。
请问如何能执行select sum(total) into :tot_total1 from invoice...得到tot_total1的合计值?