Can't Return a Result Set in the Given Context

Can't return a result set in the given context

Not sure this is the solution to your problem, but what about trying with a more recent version of PHP ?

PHP 5.2.4 is definitly quite old -- so, if it's a bug in PHP's mysqli driver, it might have been corrected since...

Actually, after a quick search, it seems a problem like the one you are witnessing has been introduced between PHP 5.2.3 and PHP 5.2.4 (and was still here in PHP 5.2.5).

See bug #42548 : PROCEDURE xxx can't return a result set in the given context (works in 5.2.3!!)

Are you able to test with something like PHP 5.2.9 or 5.2.10 ?

I know these are not provided by Ubuntu, even in the last Ubuntu stable version :-( You might have to compile from sources :-(


Yet another idea would be to try mith PDO_MySql adapter : maybe it would work with that one ?

It might be possible to change Adapter without causing too much trouble / without taking hours to test ?


As you are working with Zend Framework 1.9, here's another post that might interest you, and might be easier to test : stored procedure error after upgrade to 1.8

An easy solution to try that would be to go back to Zend Framework 1.7 ; would it be possible for you, just to test ?


Anyway... Good luck !

And, if you find the solution, don't forget to indicate what the problem was, and how you solved it ;-)

MySQL error, Not allowed to return a result set from a function?

You can't use a SELECT to display the message in a stored function, you are restricted to returning a single value via the RETURN statement. You'll find this covered in the documentation

Statements that return a result set can be used within a stored
procedure but not within a stored function. This prohibition includes
SELECT statements that do not have an INTO var_list clause and other
statements such as SHOW, EXPLAIN, and CHECK TABLE. For statements that
can be determined at function definition time to return a result set,
a Not allowed to return a result set from a function error occurs
(ER_SP_NO_RETSET). For statements that can be determined only at
runtime to return a result set, a PROCEDURE %s can't return a result
set in the given context error occurs (ER_SP_BADSELECT).

MYSQL ERROR: PROCEDURE can't return a result set in the given context

Check this stored proc in mysql console, if it works fine you should check your call from PHP.
I found that same problem is happen with other people.

How to solve The Statement did not return a result set error?

The fact that your program did not raise any exception is that having no results is not an exception.

You can use the execute() method of your CallableStatement. The execute method will return a boolean indicating if there was a ResultSet corresponding to the execution of your request.

Link to the Javadoc: https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#execute()

You still can get the ResultSet with the getResultSet method of the super class Statement: https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#getResultSet()

In your case, you would do the following:

boolean gotResults = myStmt.execute();
ResultSet rs = null;
if(!gotResults){
System.out.println("No results returned");
} else {
rs = myStmt.getResultSet();
}

Go MySQL stored procedure cannot return result set

With MySQL you cannot call stored procedures currently, and nor can you execute multiple statements at once apparently.

http://go-database-sql.org/surprises.html



Related Topics



Leave a reply



Submit