继承人@Shaharsh Shah 的代码:
DELIMITER $$
DROP TRIGGER /*!50032 IF EXISTS */ trig_auto_spid$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `trig_auto_spid` AFTER INSERT ON `tapes`
FOR EACH ROW BEGIN
SELECT REPLACE(TSpecID, 'TS', '') INTO @counter
FROM Tape_Specific_ID
ORDER BY TSpecID DESC LIMIT 1;
SET loopCnt = @counter + new.qty;
WHILE (@counter <= loopCnt) DO
INSERT INTO Tape_Specific_ID(TapesID, TSpecID)
VALUES (new.TapesID, CONCAT('TS', @counter));
SET @counter:=@counter + 1;
END WHILE;
END;
$$
DELIMITER ;
创建此触发器时发生错误 errorr 1193 (HY00):Uknown System variable 'loopCnt',为什么?任何帮助?