gpt4 book ai didi

MySQL:错误代码:1064。创建过程时

转载 作者:行者123 更新时间:2023-11-29 01:02:49 26 4
gpt4 key购买 nike

我找不到解决问题的方法,这是我的代码:

DELIMITER //
CREATE procedure SP_INS_fbUSER
(v_email varchar(50), v_password varchar(20), v_first_name Nvarchar(20),
v_last_name Nvarchar(20), v_full_name Nvarchar(50), v_profile_pic_arr text)
BEGIN
IF(exists(SELECT * FROM USER WHERE email = v_email)) then
BEGIN
INSERT INTO USER
(email,password,first_name,last_name,full_name,active,profile_pic_arr)
VALUES
(v_email,v_password,v_first_name,v_last_name,v_full_name,TRUE,v_profile_pic_arr);
END IF;
end;
DELIMITER ;

这是错误信息:

Error Code: 1064. 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 '' at line 10

第 10 行有什么问题,如何解决?

我试过这段代码:

DELIMITER //
CREATE procedure SP_INS_fbUSER
(v_email varchar(50), v_password varchar(20), v_first_name Nvarchar(20),
v_last_name Nvarchar(20), v_full_name Nvarchar(50), v_profile_pic_arr text)
BEGIN
IF(exists(SELECT * FROM USER WHERE email = v_email)) then
BEGIN
INSERT INTO USER
(email,password,first_name,last_name,full_name,active,profile_pic_arr)
VALUES
(v_email,v_password,v_first_name,v_last_name,v_full_name,TRUE,v_profile_pic_arr);
END
--------^
END IF;
end;
DELIMITER ;

但是还是报同样的错误。然后我试试这段代码:

DELIMITER //

CREATE procedure SP_INS_fbUSER
(v_email varchar(50), v_password varchar(20), v_first_name Nvarchar(20),
v_last_name Nvarchar(20), v_full_name Nvarchar(50), v_profile_pic_arr text)
BEGIN
IF(exists(SELECT * FROM `USER` WHERE `email` = v_email)) then
BEGIN
INSERT INTO `USER`
(`email`,`password`,`first_name`,`last_name`,`full_name`,`active`,`profile_pic_arr`)
VALUES
(v_email,v_password,v_first_name,v_last_name,v_full_name,TRUE,v_profile_pic_arr);
END
END IF;
END//

DELIMITER ;

它显示:

Error Code: 1064. 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 'END IF; END' at line 12

谁能帮帮我,好吗?

最佳答案

试试这个:

DELIMITER //

CREATE procedure SP_INS_fbUSER
(v_email varchar(50), v_password varchar(20), v_first_name Nvarchar(20),
v_last_name Nvarchar(20), v_full_name Nvarchar(50), v_profile_pic_arr text)
BEGIN
IF (EXISTS(SELECT * FROM `USER` WHERE `email` = v_email)) THEN
INSERT INTO `USER`
(`email`,`password`,`first_name`,`last_name`,`full_name`,`active`,`profile_pic_arr`)
VALUES
(v_email,v_password,v_first_name,v_last_name,v_full_name,TRUE,v_profile_pic_arr);
END IF;
END //

DELIMITER ;

关于MySQL:错误代码:1064。创建过程时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30204418/

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