这个存储过程SQL命令有什么问题?

时间:2015-04-11 22:19:29

标签: mysql

我试图将此存储过程添加到MYSQL数据库中并且它一直给我错误。来自MySQL(MariaDB)的错误消息不够明确,无法告诉我查询的错误。我检查了http://www.piliapp.com/mysql-syntax-check/上的查询,它说查询语法是正确的。我不知道导致错误的是什么。你们能弄清楚出了什么问题吗?

CREATE PROCEDURE tigrenoble.postBook (
IN seller VARCHAR(7),
IN bookid INT,
IN bookcondition VARCHAR(10),
IN bookprice NUMERIC,
IN posttype CHAR,
IN postdate DATE,
IN bookdescription TEXT,
IN bookquantity INT
)
BEGIN
INSERT INTO tigrenoble.Post
(seller_dce, book_isbn, book_condition, book_price, post_date, book_description, post_type, book_quantity,post_status)
VALUES
(seller, bookid, bookcondition, bookprice, postdate, bookdescription, posttype, bookquantity,'A');
END;

MariaDB说:

MariaDB [tigrenoble]> CREATE PROCEDURE tigrenoble.postBook (
-> IN seller VARCHAR(7),
-> IN bookid INT,
-> IN bookcondition VARCHAR(10),
-> IN bookprice NUMERIC,
-> IN posttype CHAR,
-> IN postdate DATE,
-> IN bookdescription TEXT,
-> IN bookquantity INT
-> )
-> BEGIN
-> INSERT INTO tigrenoble.Post
-> (seller_dce, book_isbn, book_condition, book_price, post_date, book_description, post_type, book_quantity,post_status)
-> VALUES
-> (seller, bookid, bookcondition, bookprice, postdate, bookdescription, posttype, bookquantity,'A');
 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 15
 MariaDB [tigrenoble]> END;
 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'END' at line 1

1 个答案:

答案 0 :(得分:2)

尝试使用delimiter

DELIMITER $$

CREATE PROCEDURE tigrenoble.postBook (
IN seller VARCHAR(7),
IN bookid INT,
IN bookcondition VARCHAR(10),
IN bookprice NUMERIC,
IN posttype CHAR,
IN postdate DATE,
IN bookdescription TEXT,
IN bookquantity INT
)
BEGIN
    INSERT INTO tigrenoble.Post(seller_dce, book_isbn, book_condition, book_price, post_date, book_description, post_type, book_quantity, post_status)
    VALUES(seller, bookid, bookcondition, bookprice, postdate, bookdescription, posttype, bookquantity, 'A');

END$$

DELIMITER ;