如果在存储过程中,我正在使用if else 但是会产生错误
错误代码:1064 您的SQL语法有误;检查与您的MariaDB服务器版本相对应的手册以使用正确的语法 在“ SELECT'0”响应代码附近,“请输入年龄!!!” responseMessage; 第35行的ELSEIF IFNUL'
我不知道我的程序在哪里出现语法错误
DELIMITER $$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE `saathi`.`proc_test`(
p_nameAlias VARCHAR(50),
p_age VARCHAR(50),
p_dob DATE,
p_gender VARCHAR(50),
p_email VARCHAR(50),
p_occupation VARCHAR(50),
p_educationLevel VARCHAR(50),
p_userName VARCHAR(50),
p_password VARCHAR(50),
p_district INT(11),
p_state INT(11),
p_placeofOrigin VARCHAR(50),
p_mobile VARCHAR(50),
p_maritalStatus VARCHAR(50),
p_behaviour VARCHAR(50),
p_hydc VARCHAR(50)
)
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
IF IFNULL(P_nameAlias,'')=''
THEN
SELECT '0' responseCode, 'Please enter name!!!' responseMessage;
ELSEIF IFNULL(p_dob,'')=''
THEN
SELECT '0' responseCode, 'Please enter dob!!!' responseMessage;
ELSEIF IFNULL(p_age,'')=''
SELECT '0' responseCode,'Please enter age!!!' responseMessage;
ELSEIF IFNULL(p_gender,'')=''
THEN
SELECT '0' responseCode,'Please enter gender!!!' responseMessage;
ELSE
SELECT '200' responseCode,'Tested' responseMessage;
END IF;
END IF;
END IF;
END IF;
END$$
应该可以成功编译
答案 0 :(得分:1)
ELSE和IF
之间应该有一个空格将ELSEIF
更改为ELSE IF
和
在THEN
之后放置IFNULL(p_age,'')=''