存储过程案例


DROP PROCEDURE IF EXISTS wms.chagecarpr2;
CREATE PROCEDURE wms.`chagecarpr2`()
BEGIN
declare i_rowon int default 0;
declare first_i_rowon int default 0;
declare so_id decimal(9,0);
declare so_no decimal(2,0);
declare carr_id decimal(9,0);
declare i_maxon INT;
declare first_i_maxon int;

declare first_cso_curon cursor for select ShipOrderID,SequenceNO,CarrierPrimary from twms_customershiporder where CSOStatus in(9953,9952) and CarrierPrimary is not null;
select count(*) into first_i_maxon from twms_customershiporder where CSOStatus in(9953,9952) and CarrierPrimary is not null;


open first_cso_curon;
getdataonfirst:loop
set first_i_rowon=first_i_rowon+1;
if first_i_rowon<first_i_maxon then
fetch first_cso_curon into so_id,so_no,carr_id;
update twms_customershiporder set SelectedCarrier=carr_id where ShipOrderID=so_id and SequenceNO=so_no;
ITERATE getdataonfirst;
end if;
leave getdataonfirst;
end loop getdataonfirst;
close first_cso_curon;


END;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值