高手请看!

本存储过程中的begin end 之间的语句如下: 

BEGIN 

select count(*) as t110034_count 
from t110034 
where locate(c110277 , weekday(c110270)+1) >0 and c110278 < CURRENT_DATE 
into @t110034_count; 

select min(tid110034) 
from t110034 
where locate(c110277 , weekday(c110270)+1) >0 and c110278 < CURRENT_DATE 
into @t110034_min; 

declare t110034_i integer; 
set t110034_i = convert(integer(), @t110034_min); 

while t110034_i< = convert(integer(), @t110034_count) do 
begin 
   select getseq('t100044') into @tid100044_get; 

   insert into t100044 (tid100044, c100369, c100422,c110251, c100437, c100439, c100423, c100372,c100420, 
   c100373, c100374, c100375, c100377, c100383, c100384,c100399, c100421, c100462, c100464, c100378) 
   select @tid100044_get, c110255, c110256, c110257, c110258, c110259, c110260, c110261, c110262,c110263, 
   c110264, c110265, c110266, c110267, c110269, c110270, c110271, c110272, c110273, c110274 
   from t110034 
   where tid110034 = t110034_i; 

   insert into t100044_p_big(tid, user_id, usergroup_id) 
   select @tid100044_get, user_id, usergroup_id 
   from t110034_p_big 
   where tid = t110034_i; 

   update t110034 set c110278=CURRENT_DATE 
   where tid110034 = t110034_i; 

end 
end while; 
  
END 




大致意思就是:在条件“locate(c110277 , weekday(c110270)+1) >0 and c110278 < CURRENT_DATE”下查询出表t110034里面的数据,通过循环复制到表t100044中,为什么要用循环?因为t100044表中的主键和表t100044_p_big中的tid一样都是通过自定义函数getseq('t100044')获得!此处用循环还有一点,就是此存储过程结合事件调度器使用,在条件“locate(c110277 , weekday(c110270)+1) >0 and c110278 < CURRENT_DATE”下并不是一条数据,有可能同时有多条数据符合条件。 

请高手修改下上面的存储过程,或者利用游标书写一个新的存储过程!谢谢! 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值