MySQL 8.0 C API Developer Guide
unsigned int mysql_stmt_errno(MYSQL_STMT *stmt)
For the statement specified by stmt,
mysql_stmt_errno() returns the
error code for the most recently invoked statement API
function that can succeed or fail. A return value of zero
means that no error occurred. Client error message numbers are
listed in the MySQL errmsg.h header file.
Server error message numbers are listed in
mysqld_error.h. Errors also are listed at
Error Messages and Common Problems.
If the failed statement API function was
mysql_stmt_close(), do not
call or mysql_stmt_errno() to
obtain error information because
mysql_stmt_close() makes the
statement handler invalid. Call
mysql_errno() instead.