码迷,mamicode.com
首页 > 数据库 > 详细

mysql存储过程批量删除

时间:2014-11-11 20:53:35      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:sp   bs   sql   mysql   nbsp   c   app   rom   存储   

SP:BEGIN
  WHILE instr(_checkstr,_str) <>0 DO

  SELECT sortNum  INTO @V FROM InApp_job WHERE jobId = substring(_checkstr,1,instr(_checkstr,_str)-1);
  DELETE FROM InApp_job WHERE jobId = substring(_checkstr,1,instr(_checkstr,_str)-1);
  UPDATE InApp_job SET sortNum=sortNum-1 WHERE sortNum>@V;
  SET _checkstr=REPLACE(_checkstr,substring(_checkstr,1,instr(_checkstr,_str)),‘‘);
 
  END WHILE;
 
  SELECT sortNum into @v FROM InApp_job WHERE jobId =_checkstr;
  DELETE FROM InApp_job WHERE jobId =_checkstr;
  UPDATE InApp_job SET sortNum=sortNum-1 WHERE sortNum >@v;

  IF ROW_COUNT() <> 1
  THEN
    SET _RTN = 1300;
    LEAVE SP;
  END IF;

  SET _RTN = 1;
END

mysql存储过程批量删除

标签:sp   bs   sql   mysql   nbsp   c   app   rom   存储   

原文地址:http://www.cnblogs.com/Fly-Wind/p/4090303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!