Hi,
I am having a problem that drives me nuts and I hope that someone can help me. I have the following sequence of code in C/C++:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// db is a valid pointer to a database
MYSQL* conn = db->getConnection();
MYSQL_STMT* stmt = mysql_stmt_init(conn);
// sql is a valid mysql statement
mysql_stmt_prepare(stmt, sql.c_str(), sql.length());
// bindVariables are all defined properly
mysql_stmt_bind_param(stmt, bindVariables);
my_bool getMaxLength = true;
mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &getMaxLength);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
So far, so good. If I am now calling
if (mysql_stmt_store_result(stmt))
{
LOG_ERROR("Failed to store the query results to the client. "<< mysql_stmt_error(stmt));
return false;
}
I get an error with mysql_stmt_error(stmt)="Commands out of sync; you can't run this command now"
This happens ONLY when I am using the embedded server of mysql-5.5.16. If I am using an older version of the embedded server of mysql-5.0.21, everything works fine.
According to the documentation, the above sequence is the correct way to use prepared statements when the size of the query result is not known a priori:
http://dev.mysql.com/doc/refman/5.5/en/mysql-stmt-fetch.html
Can anyone help, please
http://dev.mysql.com/doc/refman/5.5/en/mysql-stmt-fetch.html
Any ideas? Thanks a lot.
Dominikus