B.2 Types of Error Values

When an error occurs in MySQL, the server returns two types of error values:

A message string that provides a textual description of the error is also available.

When an error occurs, the MySQL error code, SQLSTATE value, and message string are available using C API functions:

For prepared statements, the corresponding error functions are mysql_stmt_errno(), mysql_stmt_sqlstate(), and mysql_stmt_error(). All error functions are described in Section 23.8, “MySQL C API”.

The number of errors, warnings, and notes for the previous statement can be obtained by calling mysql_warning_count(). See Section, “mysql_warning_count()”.

The first two characters of an SQLSTATE value indicate the error class: