`
wenjie12201
  • 浏览: 148159 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
  • luoxun11: 其实这个问题的本质是用##包围变量的时候ibatis会采用St ...
    iBATIS #和$

mysql5存储过程

 
阅读更多

BEGIN
DECLARE curCouponId int;
DECLARE curPutOutUserType int;
DECLARE record_not_found int;
DECLARE cur_coupon CURSOR for select z.* from (select DISTINCT(c.couponId),c.putOutUserType from tab_template_coupon c,tab_template_coupon_sendinfo s where c.couponId = s.couponId and c.PutOutType=2) z;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET record_not_found = 1;
open cur_coupon;  
     allcoupon:LOOP  
   fetch cur_coupon into curCouponId,curPutOutUserType;
   IF record_not_found THEN
       LEAVE allcoupon;
   END IF;
   update tab_template_coupon_sendinfo set putOutUserType = curPutOutUserType where couponId = curCouponId;  
     END LOOP allcoupon; 
close cur_coupon;  

END

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics