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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。