过程中的错误 1064
Posted
技术标签:
【中文标题】过程中的错误 1064【英文标题】:Error 1064 in a procedure 【发布时间】:2013-12-12 08:28:24 【问题描述】: ERROR 1064 (42000):您的 SQL 语法有错误;检查手册 对应于您的 mysql 服务器版本,以便在 '= (se 从 tbl_Manufacturer 选择 ifnull(max(manufactureId+1),1) ) ;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
【问题讨论】:
您的错误信息中提到的代码没有出现在您发布的代码中。 【参考方案1】:尝试使用 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
【讨论】:
【参考方案2】:试试这个:
CREATE PROCEDURE ManufactureAdd(
p_manufactureName LONGTEXT,
p_address LONGTEXT,
p_phone VARCHAR(50),
p_email VARCHAR(50),
p_description LONGTEXT
)
BEGIN
DECLARE p_manufactureId INT;
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
【讨论】:
以上是关于过程中的错误 1064的主要内容,如果未能解决你的问题,请参考以下文章
CREATE TABLE 中的 1064 错误 ... TYPE=MYISAM
MySQL 语法错误 1064 与 MS Access 中的联合查询
ERROR 1064 (42000) 过度分区语法中的数据库错误