The SQLCODE variable

The SQLCODE variable is an int4 that indicates whether the SQL statement succeeded or failed.

The header file, sqlca.h, declares SQLCODE as a global variable. Since the preprocessor automatically includes sqlca.h in the program, you do not need to declare SQLCODE.

When the database server executes an SQL statement, the database server automatically updates the SQLCODE variable as follows:
  1. The database server stores the exception value in the sqlcode field of the sqlca structure.
  2. copies the value of sqlca.sqlcode to the global SQLCODE variable.
Tip: For readability and brevity, use SQLCODE in your program in place of sqlca.sqlcode.
The SQLCODE value can indicate the following types of exceptions:
SQLCODE = 0
Success
SQLCODE = 100
NOT FOUND condition
SQLCODE < 0
Runtime error

For a description of an error message, use the finderr utility.