gpt4 book ai didi

mysql - 过程中出现错误 1064

转载 作者:行者123 更新时间:2023-11-29 08:16:21 25 4
gpt4 key购买 nike

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to use near '= (select ifnull(max(manufactureId+1),1) from tbl_Manufacturer                ) ;
create procedure ManufactureAdd(
p_manufactureName longtext,
p_address longtext,
p_phone varchar(50),
p_email varchar(50),
p_description longtext
)
begin
declare p_manufactureId = (select ifnull(max(manufactureId+1),1) from tbl_Manufacturer
) ;

insert into tbl_Manufacturer(
manufactureId,
manufactureName,
address,
phone,
email,
description
)
VALUES
(
p_manufactureId,
p_manufactureName,
p_address,
p_phone,
p_email,
p_description
) ;

SELECT p_manufactureId ;

end

最佳答案

尝试使用 SELECT..INTO 子句和简单的用户变量 -

CREATE PROCEDURE ManufactureAdd(
p_manufactureName longtext,
p_address longtext,
p_phone varchar(50),
p_email varchar(50),
p_description longtext)
BEGIN
SELECT IFNULL(MAX(manufactureId + 1), 1) INTO @p_manufactureId FROM tbl_Manufacturer;

INSERT INTO tbl_Manufacturer (manufactureId, manufactureName, address, phone, email, DESCRIPTION)
VALUES (@p_manufactureId, p_manufactureName, p_address, p_phone, p_email, p_description);

SELECT @p_manufactureId;
END

关于mysql - 过程中出现错误 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20538448/

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