开发者

Why Am I Getting MySQL Error #1312 when Using a Simple Stored Procedure?

开发者 https://www.devze.com 2022-12-31 11:33 出处:网络
I\'m trying to learn how to use MySQL stored procedures. MySQL accepted my procedure: CREATE PROCEDURE SimpleProc()

I'm trying to learn how to use MySQL stored procedures. MySQL accepted my procedure:

CREATE PROCEDURE SimpleProc()
   BEGIN
   SELECT *  FROM myTable;
   END

(In phpMyAdmin, I set // for delimiter. The real version has the name of an actual table instead of myTable.).

But, when I call the procedure with CALL SimpleProc();, I get error "#1312 - PROCEDURE mydb.SimpleProc can't return a result set in the given context".

I read that some versions of php or phpMyAdmin won't work with stored procedures.

I'm using a localhost running on a M开发者_如何转开发ac with MAMP 1.9. I've got MySQL 5.1.44, PHP 5.2.13 & 5.3.2, phpMyAdmin 3.2.5. Does anyone know if stored procedures will work with my set-up? Am I doing something incorrectly? Any advice?

Shout out to the Big Red for a triple overtime victory in Lax.

Thanks, Laxmidi


Yes, there seems to be a bug in some older versions of phpMyAdmin, which can cause the 1312 error you are getting. This can happen when calling stored procedures that contain SELECT statements from phpMyAdmin.

You may want to check out the following posts for further reading:

  • MySQL Stored Procedures not working with SELECT (basic question)
  • How do I write an SP in phpMyAdmin (MySQL)? (comments)

This bug effects only phpMyAdmin, and you would still be able to call the stored procedure from anywhere else.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号