Error Number 1312 Procedure
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Stored Procedures not working with SELECT (basic question) up vote 3 down vote favorite I am using a platform (perfectforms) that requires me to use stored procedures for most of my queries, and having never used stored procedures, I can't figure out what I'm doing wrong. The following statement executes without error: DELIMITER // DROP PROCEDURE IF EXISTS test_db.test_proc// CREATE PROCEDURE test_db.test_proc() SELECT 'foo'; // DELIMITER ; But when I try to call it using: CALL test_proc(); I get the following error: #1312 - PROCEDURE test_db.test_proc can't return a result set in the given context I am executing these statements from within phpmyadmin 3.2.4, PHP Version 5.2.12 and the mysql server version is 5.0.89-community. When I write a stored procedure that returns a parameter, and then select it, things work fine (e.g.): DELIMITER // DROP PROCEDURE IF EXISTS test_db.get_sum// CREATE PROCEDURE test_db.get_sum(out total int) BEGIN SELECT SUM(field1) INTO total FROM test_db.test_table; END // DELIMITER ; works fine, and when I call it: CALL get_sum(@t); SELECT @t; I get the sum no problem. Ultimately, what I need to do is have a fancy SELECT statement wrapped up in a stored procedure, so I can call it, and return multiple rows of multiple fields. For now I'm just trying to get any select working. Any help is greatly appreciated. mysql sql stored-procedures mysql-error-1312 share|improve this question edited May 23 '11 at 5:55 OMG Ponies 199k36356415 asked Mar 2 '10 at 1:40 TMG 3701313 When you say CALL myproc(); I assume you mean CALL test_proc();? –Atli Mar 2 '10 at 1:53 Yes - sor
to bring MySQL to the Web Brought to you by: ibennetch, nijel Summary Files Reviews Support Support Requests Patches Feature Requests Bugs Translations News Discussion Code Donate Demo Download Create Ticket View Stats Group 3.5.1 3.5.5 Latest_Git Latest_Git_snapshot 4.0.5 4.0.7 4.1.9 4.1.13 4.2.1 4.2.2 4.2.6 4.2.9 4.2.13 4.3.4 4.3.6 4.3.7 4.3.9 4.4.0 4.4.1 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.4.10 4.4.11 Searches Changes Closed Tickets Open Tickets Todo Tickets Help Formatting Help #3634 select http://stackoverflow.com/questions/2360371/mysql-stored-procedures-not-working-with-select-basic-question in stored procedure returns error #1312 Milestone: 3.4.10 Status: fixed Owner: nobody Labels: Data insertion/extraction/manipulation (334) Priority: 5 Updated: 2013-06-11 Created: 2012-07-03 Creator: Michele Salvador Private: No I create a very simple procedure whit only one SELECT CREATE PROCEDURE `seleziona`() SELECT Nome FROM utenti; And then I call it CALL seleziona; in local machine no https://sourceforge.net/p/phpmyadmin/bugs/3634/ problem phpMyAdmin 3.4.9 server Apache 2.2.21 (Win32) PHP 5.3.9 MySQL 5.5.20-log But in production online server phpMyAdmin 3.4.10.1 server Apache 2.2.22 PHP 5.3.10 MySQL 5.1.56-log when from SQL window I call this procedure (or every other with a select statement ) phpMyAdmin returns the error #1312 - PROCEDURE my_database.seleziona can't return a result set in the given context Discussion Michele Salvador - 2012-07-03 milestone: --> 3.4.10 If you would like to refer to this comment somewhere else in this project, copy and paste the following link: Michele Salvador - 2012-07-06 I started using phpMyAdmin latest version 3.5.1 this problem of the SELECT in routines seems to have fixed. :-) If you would like to refer to this comment somewhere else in this project, copy and paste the following link: Marc Delisle - 2012-07-06 status: open --> closed If you would like to refer to this comment somewhere else in this project, copy and paste the following link: Marc Delisle - 2012-07-0
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://dba.stackexchange.com/questions/33986/cant-return-a-result-set-in-the-given-context-error-when-calling-stored-proce policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; error number it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top “can't return a result set in the given context” error when calling stored procedure - differences between mysql 5.0 and 5.5? up vote 1 down vote favorite 1 I have a stored error number 1312 procedure to regenerate leafs (nleft, nright) in simple (id, id_parent) tree. (sample table) When I'am calling CALL EdgeListToNestedSet( 'category', 'id_category', 'id_parent'); it works great with version 5.5.29 of mysql but on 5.0.26 I've got an error: #1312 - PROCEDURE test.EdgeListToNestedSet can't return a result set in the given context Any ideas what can be wrong and how to make it working? mysql stored-procedures share|improve this question asked Feb 1 '13 at 17:56 ts. 12216 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Older versions of phpMyAdmin have issues with MySQL. This has been asked 8 times in StackOverflow with the tag mysql-error-1312. This bug was seen and addressed in MySQL 5.0.09 beta about 6 weeks after MySQL 5.0.26 was released Oct 09, 2006. Still, you got this error. According to http://qasimbadami.wordpress.com/tag/mysql-error-1312/, you should make sure you are using mysqli / PDO. share|improve this answer answered Feb 1 '13 at 22:43 RolandoMySQLDBA 108k15138274 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your