SQLCODE, SQLMSG, and SQLERRD can now be defined outside of the SQL declaration section. Under the conditions listed below, SQL statement runtime information was not stored in V10.1.0. In V10.2.0 and later, runtime information is stored in SQLCODE, SQLERRD, and SQLMSG.
SQLSTATE is described inside the SQL declaration section, and
SQLCODE, SQLERRD, or SQLMSG are described outside the SQL declaration section, and
SQL statements are executed, and
SQLCODE, SQLERRD, or SQLMSG are referred to in the PROCEDURE DIVISION, and
Conditions 1 through 4 are occurred in the same compilation unit.
In V10.2.0 and later, SQLCODE, SQLERRD, and SQLMSG are reserved names used to fetch SQL statement runtime information. If you have variables by those names that are used for any other purpose, the results are unpredictable. In this case, change the names of those variables.