Runtime errors in SQLCODE

When an SQL statement results in a runtime error, the database server sets SQLCODE (and sqlca.sqlcode) to a negative value. The actual number identifies the particular error. The error message documentation lists the error codes specific to HCL Informix® and their corrective actions.

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

From within your Informix® ESQL/C program, you can retrieve error message text that is associated with a negative SQLCODE (sqlca.sqlcode) value with the rgetlmsg() or rgetmsg() library function.

When the database server encounters a runtime error, it might also set the following other fields in the sqlca structure:
  • sqlca.sqlerrd[1] to hold the additional ISAM error return code. You can also use the rgetlmsg() and rgetmsg() library functions to obtain ISAM error message text.
  • sqlca.sqlerrd[2] to indicate the number of rows processed before the error occurred in a multirow INSERT, UPDATE, or DELETE statement.
  • sqlca.sqlerrm is used differently depending on what type of database server is using it.

    If the server is the HCL Informix® database server this value is set to an error message parameter. This value is used to replace a %s token in the error message.

    For example, in the following error message, the name of the table (sam.xyz) is saved in sqlca.sqlerrm:
    310: Table (sam.xyz) already exists in database.

    If the server is theDB2® database server this field is set to the complete error message.

  • sqlca.sqlerrd[4] after a PREPARE, EXECUTE IMMEDIATE, or DECLARE statement that encountered an error.
Tip: You can also test for errors with the WHENEVER SQLERROR statement.