gpt4 book ai didi

MySQL:如果在存储过程中

转载 作者:IT王子 更新时间:2023-10-29 00:31:10 25 4
gpt4 key购买 nike

我刚刚接触存储过程。根据我看过的教程,这应该是有效的(MySQL 5.5):

CREATE PROCEDURE someFunction ( a VARCHAR(256),  b VARCHAR(256) )
BEGIN
DECLARE haveAllVariables INT;
SET haveAllVariables = 1;

IF a = "" THEN SET haveAllVariables = 0
ELSEIF b = "" THEN SET haveAllVariables = 0
END IF;

但是,它抛出这个错误:

ERROR 1064 (42000): 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 'ELSEI
F b = "" THEN SET haveAllVariables = 0

我的语法错误在哪里?

谢谢。

最佳答案

你少了一个分号

CREATE PROCEDURE someFunction ( a VARCHAR(256),  b VARCHAR(256) )
BEGIN
DECLARE haveAllVariables INT;
SET haveAllVariables = 1;

IF a = "" THEN SET haveAllVariables = 0;
ELSEIF b = "" THEN SET haveAllVariables = 0;
END IF;

关于MySQL:如果在存储过程中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9649797/

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