gpt4 book ai didi

mysql 错误 1193 (HY00) : Uknown System variable 'loopCnt'

转载 作者:行者123 更新时间:2023-11-29 02:01:11 25 4
gpt4 key购买 nike

这是来自@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',为什么?有什么帮助吗?

最佳答案

让它成为用户变量

SET @loopCnt := @counter + new.qty; 
WHILE (@counter <= @loopCnt) DO

更新 1

SET @counter := 10;
SET @loopCnt := @counter + new.qty;
WHILE (@counter <= @loopCnt) DO

关于mysql 错误 1193 (HY00) : Uknown System variable 'loopCnt' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14395945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com