MySQL服务器存储过程语法错误 [英] MySQL server stored procedure syntax error
问题描述
我在为MySQL数据库创建存储过程时遇到了一些麻烦。
这里是一个Select语句:
使用canningi_db_person_cdtest;
SELECT *
FROM pet
WHERE name ='Puffball';
这是我的存储过程不工作:
使用canningi_db_person_cdtest;
CREATE PROCEDURE GetAllPets()
BEGIN
SELECT *
FROM pet
WHERE name ='Puffball';
END
我收到以下错误:
#1064 - 您的SQL语法有错误;检查对应于您的MySQL服务器版本的手册以获得正确的语法在第5行使用
接近''
如何调用此存储地址?
程序?我试过这个没有结果: 使用canningi_db_person_cdtest;
CALL GetAllPets();
这是错误:
#1312 - PROCEDURE canningi_db_person_cdtest.GetAllPets无法在给定上下文中返回结果集
添加分隔符以结束过程。示例:
使用canningi_db_person_cdtest;
DELIMITER //
CREATE PROCEDURE GetAllPets()
BEGIN
SELECT *
FROM pet
WHERE name ='Puffball ';
END //
如果您需要更多信息,请参阅 http://dev.mysql.com/doc/refman/5.1/en/ stored-programs-defining.html
I am having some trouble with creating a Stored Procedure for a MySQL database.
Here is a Select statement that works:
use canningi_db_person_cdtest;
SELECT *
FROM pet
WHERE name = 'Puffball';
Here is my Stored Procedure that does not work:
use canningi_db_person_cdtest;
CREATE PROCEDURE GetAllPets()
BEGIN
SELECT *
FROM pet
WHERE name = 'Puffball';
END
I am getting the following error:
#1064 - 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 '' at line 5
How can I get this working?
EDIT
How do I call this Stored Procedure? I have tried this with no result:
use canningi_db_person_cdtest;
CALL GetAllPets();
This is the error:
#1312 - PROCEDURE canningi_db_person_cdtest.GetAllPets can't return a result set in the given context
Add a delimiter to end your procedure. Example:
use canningi_db_person_cdtest;
DELIMITER //
CREATE PROCEDURE GetAllPets()
BEGIN
SELECT *
FROM pet
WHERE name = 'Puffball';
END//
If you need more information, please refer to http://dev.mysql.com/doc/refman/5.1/en/stored-programs-defining.html
这篇关于MySQL服务器存储过程语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!