存储过程-遍历更新20181227

CREATE DEFINER=`root`@`localhost` PROCEDURE `NewProc`()
BEGIN
DECLARE _word INT;
DECLARE tmpstr varchar(64);
DECLARE mes varchar(64);
DECLARE paytm INT;
DECLARE done INT DEFAULT FALSE;
DECLARE cur_pay CURSOR FOR select order_mes,updatetime from pay_order;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

OPEN cur_pay;
read_loop: LOOP
FETCH NEXT from cur_pay INTO mes,paytm;
IF done THEN
LEAVE read_loop;
END IF;

SET _word = LOCATE(',',mes);

WHILE _word > 0
DO
SET tmpstr = SUBSTR(mes,1,_word-1);
update order_orderlist set pay_tm = paytm where id = tmpstr;
SELECT * FROM order_orderlist where id = tmpstr;
SET mes = SUBSTR(mes FROM _word+1);
SET _word = LOCATE(',',mes);
END WHILE;
update order_orderlist set pay_tm = paytm where id = mes;
END LOOP;
CLOSE cur_pay;
END

转载于:https://www.cnblogs.com/daochong/p/10185847.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值