gpt4 book ai didi

Mysql存储过程语法错误1064

转载 作者:行者123 更新时间:2023-11-29 03:34:16 24 4
gpt4 key购买 nike

我有一个 MySQL 存储过程。是这样的:

CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
SET @x = 1;
REPEAT

INSERT INTO `edittables` (`USER_ID`, `REFERENCETYPE`, `COLUMNNAME`, `VERSION`, `CREATEDDATETIME`, `LASTUPDATEDDATETIME`) VALUES
(@x ,12,'type', 0, "2014-08-12 00:00:00", "2000-08-12 00:00:00");

SET @x = @x + 1;
UNTIL @x > p1 END REPEAT;
END
//

我收到这个错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REPEAT

INSERT INTO `edittables` (`USER_ID`, `REFERENCETYPE`, `COLUMNNAM' at line 1

有什么想法吗?

最佳答案

试试这个

DELIMITER //   
CREATE PROCEDURE dorepeat(p1 INT)
BEGIN
DECLARE x INTEGER;
SET x = 1;
REPEAT
INSERT INTO `edittables` (`USER_ID`, `REFERENCETYPE`, `COLUMNNAME`,`VERSION`, `CREATEDDATETIME`, `LASTUPDATEDDATETIME`) VALUES (X ,12,'type', 0, "2014-08-12 00:00:00", "2000-08-12 00:00:00");
SET x = x + 1;
UNTIL x > p1
END REPEAT;
END //
DELIMITER ;

关于Mysql存储过程语法错误1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25279297/

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