I’ve done some searches and scrutinized the C Programming API that is here:
http://dev.mysql.com/doc/refman/5.1/en/c-api-prepared-statement-functions.html
Most of it geared towards fetching rows of data that come back, which is easy. The sproc is being called like this from the C program (I know I should bind the parameters I will…) :
sprintf( cmd, "CALL get_graph_data( \"%s\", \"%s\");", symbol, scope );
if (mysql_query(conn, cmd)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
if( res == NULL ) { ; // how do I get output parameters in this case ? umm...
} else {
num_fields = mysql_num_fields(res);
while ((row = mysql_fetch_row(res)) != NULL)
{
do stuff
}
}
the SPROC that I am calling looks like this :
create procedure get_graph_data (
symbol varchar(20),
period varchar(5),
OUT status SMALLINT,
OUT emsg varchar(255)
)
SO – I can’t figure out the API calls to get at the two output parameters status and emsg. also, in the case where the sproc produces zero rows (some validation of user input has to occur in the db without having to make extra calls to do that) then ‘res’ comes back NULL so not sure how to get at output parameters in that case …
TIA !
try in this manner
first
CALL get_graph_data('xxx','yyy', @a, @b);and then
select @a, @b;UPDT
You can use simple interface instead of Prepared Statement API. But you should set enable multiple-statement execution to get values of
statusandemsg. Then “out of sync” error should disappear.