gpt4 book ai didi

MySQL无法创建过程

转载 作者:行者123 更新时间:2023-11-29 00:46:38 24 4
gpt4 key购买 nike

我正在尝试创建一个程序(将新的类名、类型、国家/地区、火炮数量、口径和排水量作为参数。将此信息添加到类中,并将具有类名的船舶添加到船舶中)

关系:

classes(class, type, country, numGuns, bore, displacement)
ships(name, class, launched)


mysql> CREATE PROCEDURE addClass(in VARCHAR(50) inClassName, in VARCHAR(5) inType, in
VARCHAR(50) inCountry, in INT inNumGuns, in INT inBore, in INT inDis)
-> begin
-> INSERT INTO classes VALUES(inClassName, inType, inCountry, inNumGuns, inBore, inDis);
-> INSERT INTO ships VALUES(inClassName, inClassName, NULL);
-> end
-> //
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 'VARCHAR(50)
inClassName, in VARCHAR(50) inType, in VARCHAR(50) inCountry, in INT' at line 1

我不确定这个错误的来源,任何人都可以帮忙吗?

最佳答案

输入变量名出现在它们的数据类型之前,而不是像您指定的那样出现在它们之后:

CREATE PROCEDURE addClass(
in inClassName VARCHAR(50),
in inType VARCHAR(5) ,
in inCountry VARCHAR(50),
in inNumGuns INT,
in inBore INT,
in inDis INT
)
BEGIN
INSERT INTO classes VALUES(inClassName, inType, inCountry, inNumGuns, inBore, inDis);
INSERT INTO ships VALUES(inClassName, inClassName, NULL);
END

From the CREATE PROCEDURE docs , 规范看起来像

proc_parameter:
[ IN | OUT | INOUT ] param_name type

关于MySQL无法创建过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10285754/

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