我很可能有语法问题(SQL命令和下面复制的错误) - 我在Ubuntu 11上使用MySQL v5.1.63(dbName是数据库的名称,提到的字段在USERS表中包含相应的数据类型/长度)。任何解决这个问题的建议都会受到欢迎。
use dbName;
DELIMITER //
CREATE PROCEDURE sp_insertTest
(
IN p_ID INT(11),
IN p_UserID VARCHAR(40),
IN p_Email VARCHAR(30)
)
BEGIN
INSERT INTO USERS
(
ID,
UserID,
Email
)
VALUES
(
p_ID,
p_UserID,
p_Email
)
END//
DELIMITER;
当我获取包含上述语句的文件时,我收到错误:
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 'END' at line 32
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 'DELIMITER' at line 1
提前致谢。
答案 0 :(得分:0)
尝试在END//
和DELIMITER;
之后添加空格,并在插入的值后尝试使用分号。更正的程序是:
DELIMITER //
CREATE PROCEDURE sp_insertTest
(
IN p_ID INT(11),
IN p_UserID VARCHAR(40),
IN p_Email VARCHAR(30)
)
BEGIN
INSERT INTO USERS
(
ID,
UserID,
Email
)
VALUES
(
p_ID,
p_UserID,
p_Email
);
END //
DELIMITER ;