views:

198

answers:

2

Hello,

I have a problem calling a stored procedure on my MySQL server using the C API.

I use mysql_query(&handle,"CALL myprocedure") but the function fails (returns 1) and error lookup gives the following message "Procedure myprocedure can't return a result set in the given context." I even tried to use mysql_real_query insted, but no better.

I've seen a few topics about this bug, but only PHP related. So there seems to be the same problem for C programs too.

The weird thing is that my stored procedure is not even supposed to return any result set. It just works with data in tables, doesn't really return anything.

Thanks for any advices.

A: 
noonex
Yeah, I tried that, but it works...However I already solved the problem by adding the CLIENT_MULTI_STATEMENTS flag in the mysql_real_connect.but thanks for answering anyway
NumberFour
+1  A: 

Refer to functions:
mysql_set_server_option() &
mysql_real_connect()
here.

Multiple statements are only enabled(temporarily) using the MYSQL_OPTION_MULTI_STATEMENTS_ON and _OFF arguments to mysql_set_server_option().

The problem here is that CLIENT_MULTI_STATEMENTS in mysql_real_connects() implicitly enables CLIENT_MULTI_RESULTS, too, but MYSQL_OPTION_MULTI_STATEMENTS_ON only enables multiple statements, not multiple results.

So add CLIENT_MULTI_STATEMENTS on connect and try again.

mtanish
Well, I had no flags in my mysql_real_connect, but when I added the CLIENT_MULTI_STATEMENTS it suddenly started to work... weird though... But at least its working now... Thanks
NumberFour