简体   繁体   English

简单存储过程参数导致未知错误

[英]Simple stored procedure parameter is causing an unknown error

It's a simple procedure, I just cannot for the life of me find the error in this syntax.这是一个简单的过程,我一生都找不到这种语法中的错误。 I've learned at other posts and couldn't find a working solution.我在其他帖子中学习过,但找不到有效的解决方案。

CREATE PROCEDURE cooldownUpdate @command VARCHAR(18)
AS
UPDATE `mention_cooldowns` SET cooldown = 'true' WHERE command = @command
GO;

You have an error in your SQL syntax;您的 SQL 语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near ' @command VARCHAR(18) AS UPDATE mention_cooldowns SET cooldown = 'true' WHERE c ' at line 1检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“ @command VARCHAR(18) AS UPDATE mention_cooldowns SET cooldown = 'true' WHERE c ”附近使用正确的语法

Firstly, you have to set a delimiter while creating stored procedure.首先,您必须在创建存储过程时设置分隔符。 Also, you have to define whether the parameter is for IN or OUT and finally you have to wrap your queries inside BEGIN and END for best practice.此外,您必须定义参数是用于IN还是OUT ,最后您必须将查询包装在BEGINEND中以获得最佳实践。

Please check below for creating stored procedure.请检查以下内容以创建存储过程。

DELIMITER //

CREATE PROCEDURE cooldownUpdate(IN pCommand VARCHAR(18))
BEGIN
    UPDATE `mention_cooldowns` SET cooldown = 'true' WHERE command = pCommand;
END //

DELIMITER ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM