contents.gifindex.gifprev1.gifnext1.gif

Informix: Retrieving Errors

You can determine the meanings of Informix database and ISAM error codes by referring to the Informix documentation. Here are four methods for storing the complete error code and some helpful text that describes it:

Method One

At runtime, if you specify an error file and use the -x option, the runtime puts the extended error code and some text associated with the error into the error file. You'll see three levels of error codes in the file: ACUCOBOL-GT error, Informix database error, and ISAM error. A value of zero for any level means no error at that level.

For example:

runcbl -le errfile -x yourprog

-l causes the contents of the runtime configuration file to be included in the error output

-e causes the error output to be placed in the file named immediately after the option

errfile is the user-specified name of the error file

-x causes the extended error numbers to be included

yourprog is the name of your object file

The text of the error would then have this format in the file:

*** File system error value = 1 ***

*** DATABASE not defined in environment ***

File error 9D,01 on filename

DATABASE not defined in environment

Method Two

Informix error code 201 indicates a syntax error. We can help you examine the error file and determine the cause of the problem if you receive this error code. We'll need you to rerun the program, specifying the options shown below, and turning on Trace Files (TF) when execution begins:

runcbl -dle errfile -x yourprog

Notice that the only change from Method One is the -d option, which turns on the debugger. The source code does not need to be compiled in debug mode.

After you press <return>, you will be at the debugger screen. Type:

tf <return>

FILE TRACE will be echoed on the screen. Type:

g <return>

You will now be running your program normally. Proceed until you encounter the error condition, and then exit. Your error file will contain the error information described in Method One, above, and will also contain the SQL queries that the interface constructed. Examining these queries can help to determine the cause of the 9D 201 syntax error.

Method Three

You might want to separate the error codes and their associated text, and store them in variables. The variables can then be displayed to the screen or handled in whatever way you deem appropriate.

Remember that the extended code can consist of two parts (database error and ISAM error), separated by a comma. In the example shown below, we use the library routine C$RERR with two parameters to retrieve the complete error code (first parameter) and its associated text (second parameter). Then we use the UNSTRING verb to separate the code into its parts:

DATA DIVISION
 .
 .
 .
working-storage section.

01 file-status         pic xx.
01 error-status.
 03 primary-error      pic x(2).
 03 extended-error     pic x(40).
01 secondary-error     pic x(10).
01 isam-error          pic x(40).
01 error-text          pic x(40).

PROCEDURE DIVISION
 .
 .
 .
get-file-err.
 call "C$RERR" using error-status, error-text.
 unstring extended-error delimited by "," into
  secondary-error, isam-error.

 display "FILE ERROR:, primary-error.
 display "DATABASE ERROR:", secondary-error.
 display "ISAM ERROR:", isam-error.

 display error-text.
 accept omitted.
 stop run.
Here's an example of the output you might get from this:

FILE ERROR: 9D

DATABASE ERROR: 350
ISAM ERROR: 108
Index already exists on column.

Method Four

The fourth method allows you to take the Informix error number and use the "finderr" syntax to discover error information. More information on this syntax can be found in your Informix documentation.

The syntax is:

finderr xxxxx (where xxxxx is the Informix error number)