Previous Topic: Inspect Host VariablesNext Topic: How to Handle SQL Error Codes


SQL Return Codes

The SQL communication area (SQLCA) is a structure of variables that is updated after each SQL statement executes. An application program that contains executable SQL statements must provide an SQLCA to let DB2 or SQL/DS to communicate with the program.

Note:The IBM manual DB2 Application Programmer Guide provides information on the SQLCA.

When DB2 or SQL/DS processes an SQL statement, it places a return code in the SQLCODE field of the SQLCA that indicates the success or failure of the SQL request:

Note: Sometimes a zero return code does not indicate a successful execution. You should always check the SQLWARN field to ensure that it is blank, which indicates successful execution. If the field is not blank, a warning condition exists. Check the other warning indicators to determine the specific condition.

Example

If a value was truncated the SQLCODE will be zero, but the SQLWARN1 field indicates truncation.

Because the SQLCA contains valuable diagnostic information, it is a good idea to check its contents after each SQL request.