Although you can check your data source documentation for error code information, the easiest way to determine which error codes need to be mapped to more appropriate COBOL codes is through trial and error. As users use Database Connectors DB2, they may report receiving error messages that don't make sense based on their situation. Research these errors and try to determine a more appropriate COBOL error response.
When you create your error map file, use the following guidelines:
The following example leads to the entry in the sample DB2 error file:
OdbcOneInfo: State: 23505, Native Error: -803 '[IBM][CLI Driver][DB2/NT]SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because they would produce duplicate rows for a table with a primary key, unique constraint, or unique index. SQLSTATE=23505' Setting f_errno = 19 Leaving, error ***File system error value = -803 *** >>>file status = 9S,-803
Using the same example, you would include this line in the error_map file:
-803 E_DUPLICATE
The valid values for the second field are as follows:
E_SYS_ERR E_PARAM_ERR E_TOO_MANY_FILES E_MODE_CLASH E_REC_LOCKED E_BROKEN E_DUPLICATE E_NOT_FOUND E_UNDEF_RECORD E_DISK_FULL E_FILE_LOCKED E_REC_CHANGED E_MISMATCH E_NO_MEMORY E_MISSING_FILE E_PERMISSION E_NO_SUPPORT E_NO_LOCKS
The file DB2.err contains some initial file error mappings.