厄,折腾了一下午,一直在报错,放这里,方便以后察看
DELIMITER $$
![](/Images/OutliningIndicators/None.gif)
DROP PROCEDURE IF EXISTS `qqnum`.`delqqnum`$$
![](/Images/OutliningIndicators/None.gif)
CREATE DEFINER=`admin`@`127.0.0.1` PROCEDURE `delqqnum`(in qqnumber varchar(32))
BEGIN
DECLARE pos int;
DECLARE sqlStr varchar(500);
DECLARE tabStr varchar(500);
DECLARE sTabStr varchar(128);
SET @tabStr = 'qq200704,qq200708,qq200709';
main:LOOP
SET @sTabStr = SUBSTRING_INDEX(@tabStr, ',', 1);
SET @sqlStr = CONCAT('DELETE FROM ',@sTabStr,' WHERE qqnumber=',qqnumber,';');
PREPARE sqlstmt from @sqlStr;
EXECUTE sqlstmt;
DEALLOCATE PREPARE sqlstmt;
SET @pos = LOCATE(',',@tabStr);
IF @pos = 0 THEN LEAVE main; END IF;
SET @tabStr = SUBSTR(@tabStr,@pos+1);
END LOOP main;
END$$
![](/Images/OutliningIndicators/None.gif)
DELIMITER ;