首页 > 代码库 > mysql存储过程批量删除

mysql存储过程批量删除

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存储过程批量删除