gpt4 book ai didi

mysql存储过程语法错误:

转载 作者:行者123 更新时间:2023-11-29 08:56:09 26 4
gpt4 key购买 nike

我有一个 mysql 存储过程,它给了我以下错误:-

#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 4 行的 'set intoffer = 'select max(offerid) from home' if(intoffer IS NULL) then set int' 附近使用的正确语法

我已将分隔符框中的分隔符设置为;。存储过程是

create procedure sp()
begin
declare intoffer int
set intoffer = 'select max(offerid) from home'
if(intoffer IS NULL) then
set intoffer=1
else
set intoffer=intoffer+1
insert into home(offerid,offerheader,offertext,offerimage,offerlink) values(intoffer,'d','d','d','d')
end;

最佳答案

存在一些语法和其他错误。试试这个代码 -

CREATE PROCEDURE sp()
BEGIN
DECLARE intoffer INT;

SELECT max(offerid) INTO intoffer FROM home;
IF (intoffer IS NULL) THEN
SET intoffer = 1;
ELSE
SET intoffer = intoffer + 1;
END IF;
INSERT INTO home (offerid, offerheader, offertext, offerimage, offerlink) VALUES (intoffer, 'd', 'd', 'd', 'd');
END

关于mysql存储过程语法错误:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9920691/

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