If you are using SQLCA, the variable SQLERRMC contains either an SQL message if an SQL error occurred or a TIBCO Object Service Broker error message.
If SQLCA is present, it indicates that the Sqlcode variable is also present and error information must be relayed through the provided variables.
The Sqlstate status variable can be used in place of, or in addition to, the
Sqlcode and SQLCA. It is a string of five characters that relays error codes. The following table shows the possible error codes and their explanations:
You must ensure that you use the correct level number and picture clause: the preprocessor scans the host variables in the Declare section to see if
Sqlstate is mentioned. If so, it updates all successes/errors through it, in addition to
Sqlcode (if it was also mentioned in an Include SQLCA statement or on its own).
The Sqlcode status variable can be used on its own or together with
Sqlstate. If SQLCA is used, there is no need to declare
Sqlcode. If it is declared with SQLCA, the COBOL compiler can pick up two declarations and report it as an error at compile time. If you use
Sqlcode, you must ensure that the proper level number and picture clause are used.
Any of these three methods can be used to get error information but the default assumption is that
Sqlcode was properly declared. If this is not true (that is,
Sqlcode was not declared), the compiler detects an undefined variable and reports it to you at compile time.