The Scope of Variables
All variables declared in an embedded SQL declaration section can be referenced in ESQL statements and the preprocessor accepts them, from the point of declaration to the end of the file. This is not true for the COBOL compiler, which generally allows references to only those variables declared in the current program. Because the preprocessor does not terminate the scope of a variable in the same way the COBOL compiler does, do not re-declare variables of the same name to the preprocessor in a single file even where the variables are declared in separately compiled program units. If two programs in a single file each use variables of the same name and type in embedded SQL statements, only declare the first in an embedded SQL declaration section.
Last modified date: 08/28/2024