本存储过程中的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”下并不是一条数据,有可能同时有多条数据符合条件。
请高手修改下上面的存储过程,或者利用游标书写一个新的存储过程!谢谢!
高手请看!
最新推荐文章于 2024-05-06 14:20:38 发布