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:

    When we do not know the truth of a thing, it is of advantage that there should exist a common error which determines the mind of man.... For the chief malady of man is restless curiosity about things which he cannot understand; and it is not so bad for him to be in error as to be curious to no purpose.
    Blaise Pascal (1623–1662)