下面的代码给出了许多与分号相关的错误。我是 MySql
的新手,所以一无所知。
CREATE PROCEDURE `sp_get_orderbystatus`(p_status_id int)
BEGIN
declare v int;
if(p_status_id = 1) then
begin
set v = 1;
end;
end if;
END
最佳答案
如果您尝试在 mysql
cli 中执行此操作,则似乎需要更改 DELIMITER
。
DELIMITER // -- change the delimiter to '//'
CREATE PROCEDURE `sp_get_orderbystatus`(p_status_id int)
DECLARE v INT;
-- the rest of the code of your procedure
END//
DELIMITER ; -- change it back to ';'
Defining Stored Programs
If you use the mysql client program to define a stored program containing semicolon characters, a problem arises. By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.
关于mysql - 这个存储过程代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44864745/