This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file.

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 20.6, “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: