IBM DB2 - Error Processing

Error Processing

An important feature of DB2 computer programs is error handling. The SQL communications area (SQLCA) structure was once used exclusively within a DB2 program to return error information to the application program after every SQL statement was executed. The primary, but not singularly useful, error diagnostic is held in the field SQLCODE within the SQLCA block.

The SQL return code values are:

  • 0 means successful execution.
  • A positive number means successful execution with one or more warnings. An example is +100, which means no rows found.
  • A negative number means unsuccessful with an error. An example is -911, which means a lock timeout (or deadlock) has occurred, triggering a rollback.

Later versions of DB2 added functionality and complexity to the execution of SQL. Multiple errors or warnings could be returned by the execution of an SQL statement; it may, for example, have initiated a Database Trigger and other SQL statements. Instead of the original SQLCA, error information should now be retrieved by successive executions of a GET DIAGNOSTICS statement.

See SQL return codes for a more comprehensive list of common SQLCODEs.

Read more about this topic:  IBM DB2

Famous quotes containing the word error:

    It is error alone which needs the support of government. Truth can stand by itself.
    Thomas Jefferson (1743–1826)