set @num=@UnitLength/3;
label:
while i<@num do
set @length=(select SUBSTRING(@unit_sid_fk,1,@UnitLength-3*i));
set @sms_content=(select sms_content from sms_config where sms_type='smsCall' and unit_sid_fk=@length);
set @sms_counts=(select sms_counts from sms_config where sms_type='smsCall'and unit_sid_fk=@length);
if @sms_content is not null then
insert into sms_task set mt_at_time=@date,mt_content=@sms_content,unit_sid_fk=@unit_sid_fk,mt_dst_num=@calltelephone,mt_add_time=@date,mt_group_id=@groupid,branch_num=@sms_counts,mt_dst_size='1',sms_channel='SMSPORT',mt_type_id='99';
set New.sms_send='Y';
leave label;
end if;
set i=i+1;
end while;
在while循环外面添加label: 用 leave label; 即可跳出当前循环。

本文介绍了一个使用while循环和条件判断实现的批量短信任务自动发送脚本,通过解析数据库中的短信配置信息,自动为指定数量的目标进行短信发送。
2018

被折叠的 条评论
为什么被折叠?



