• Home
  • MySQL
  • PHP
  • Apache
  • About
  • Contact Us
 
 
 
  • MySQL 5.5 Reference Manual
  • MySQL 5.1 Reference Manual
  • MySQL 3.23/4.0/4.1 Manual
  • MySQL 4.0 Russian Manual


MySQL 5.5 Reference Manual :: B Errors, Error Codes, and Common Problems :: B.2 Types of Error Values
« B.1 Sources of Error Information

B.3 Server Error Codes and Messages »
Section Navigation      [Toggle]
  • B Errors, Error Codes, and Common Problems
  • B.1 Sources of Error Information
  • B.2 Types of Error Values
  • B.3 Server Error Codes and Messages
  • B.4 Client Error Codes and Messages
  • B.5 Problems and Common Errors

B.2. Types of Error Values

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

  • A MySQL-specific error code. This value is numeric. It is not portable to other database systems.

  • An SQLSTATE value. The value is a five-character string (for example, '42S02'). The values are specified by ANSI SQL and ODBC and are more standardized.

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

When an error occurs, you can access the MySQL error code, the SQLSTATE value, and the message string using C API functions:

  • MySQL error code: Call mysql_errno()

  • SQLSTATE value: Call mysql_sqlstate()

  • Error message: Call mysql_error()

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 21.9, “MySQL C API”.

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

  • '00' indicates success.

  • '01' indicates a warning.

  • '02' indicates “not found.” These values are relevant only within the context of cursors and are used to control what happens when a cursor reaches the end of a data set.

  • Other values indicate an exception.

Copyright © 1997, 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices
Previous / Next / Up / Table of Contents

Top / Previous / Next / Up / Table of Contents
Copyright © 2011, doc0.ru
All rights reserved