MySQL :: MySQL 8.4 C API Developer Guide :: 5.4.15 mysql_errno() (original) (raw)

5.4.15 mysql_errno()

unsigned int
mysql_errno(MYSQL *mysql)

Description

For the connection specified by mysql,mysql_errno() returns the error code for the most recently invoked 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 MySQLerrmsg.h header file. Server error message numbers are listed inmysqld_error.h. Errors also are listed atError Messages and Common Problems.

MySQL-specific error numbers returned bymysql_errno() differ from SQLSTATE values returned bymysql_sqlstate(). For example, the mysql client program displays errors using the following format, where 1146 is the mysql_errno() value and'42S02' is the correspondingmysql_sqlstate() value:

$> SELECT * FROM no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist

Return Values

An error code value for the lastmysql_ _`xxx`_() call, if it failed. zero means no error occurred.