mysql_stmt_sqlstate() returns the SQLSTATE value for the most recently called prepared statement API function.
Syntax
const char *
mysql_stmt_sqlstate(MYSQL_STMT *stmt)
Return values
A string that contains the SQLSTATE error code and ends with a null character.
Notes
For a statement specified by stmt, mysql_stmt_sqlstate() returns a string that ends with a null character and contains the SQLSTATE error code of the most recently called prepared statement API function. The execution of the API function can succeed or fail.
The error code consists of five characters. "00000" indicates no errors. These codes are specified by ANSI SQL and ODBC.
Not all errors are mapped to the SQLSTATE codes. The code "HY000" (general errors) is used for unmapped errors.
If the API function of a failed statement is mysql_stmt_close(), do not call mysql_stmt_sqlstate() to obtain the error information because mysql_stmt_close() invalidates the statement handle. Instead, we recommend that you call mysql_sqlstate().