[Gambas-user] MySQL stored procedures execution problem

Benoit Minisini gambas at ...1...
Tue May 29 18:02:39 CEST 2007


On mardi 29 mai 2007, Leandro Anthonioz Blanc wrote:
> Hi, I have a problem with MySQL stored procedures that returns results.
> FIRST time I execute a line like this: hResult = hConn.Exec(“CALL
> MyStoredProcedure()”)  
 line works OK. However, NEXT time I try to execute
> same line, this error occurs: “Query failed: Commands out of sync; you
> can’t run this command now”  I found this information in MySQL
> documentation: If you get Commands out of sync; you can't run this command
> now in your client code, you are calling client functions in the wrong
> order. This can happen, for example, if you are using mysql_use_result()
> and try to execute a new query before you have called mysql_free_result().
> It can also happen if you try to execute two queries that return data
> without calling mysql_use_result() or mysql_store_result() in between. To
> avoid this problem, I close and reopen connection before execute a stored
> procedure, and works, but is not a good workaround. I edit “do_query”
> function in gb.db.mysql/src/main.c file, attempting to include a
> “mysql_free_result(res);” instruction that solves the problem, but I
> couldn’t solve it. Anybody can help me please? Thank you very much.
>
>

Which version of Gambas do you use? (I should have a keyboard shortcut for 
inserting this question...)

Please send me exactly what code you are trying to run.

At first glance, gb.db.mysql does not use mysql_use_result(), and use 
mysql_store_result() each time it has run a query without error. I think I 
have a clue about what could happen, but I need your full code.

Regards,

-- 
Benoit Minisini




More information about the User mailing list