Setting External Variables

When using Database Connectors, file status variables and declarations may not be able to provide enough information to determine the cause of the error and the recommended resolution.

Setting external variables can provide additional information in troubleshooting situations. For example, if the database returns an error that does not map to one of the standard COBOL errors (record locked, duplicate key, etc.), the external variables F-ERRNO, F-INT-ERRNO, F-INT2-ERRNO and F-ERRMSG contain additional information. Typically, F-ERRNO is E_INTERNAL (which has a value of 15). F-INT-ERRNO and F-INT2-ERRNO are the error values returned by the database, and F-ERRMSG points to a text message returned by the database.

Add the following EXTERNAL declarations to working-storage:

01  F-INT-ERRNO   BINARY-LONG  SIGNED 	EXTERNAL.
01  F-INT2-ERRNO  BINARY-LONG  SIGNED	 EXTERNAL.
01  F-ERRMSG      POINTER             	EXTERNAL.
77  F-ERRNO       BINARY-SHORT SIGNED 	EXTERNAL.
Note: Not all errors return textual messages.