Was this helpful?
Variable Declarations
Host language variables must be declared to OpenSQL before using them in any embedded OpenSQL statements. Host language variables are declared to OpenSQL in a declaration section that has the following syntax:
EXEC SQL BEGIN DECLARE SECTION;
        host variable declarations
EXEC SQL END DECLARE SECTION;
A program can contain multiple declaration sections. The preprocessor treats variables that are declared in each declaration section as global to the embedded OpenSQL program from the point of declaration forward.
The variable declarations are identical to any variable declarations in the host language. The data types of the declared variables must belong to a subset of host language data types that are compatible with embedded OpenSQL data types. OpenSQL converts between host language data types and OpenSQL data types.
For a list of valid embedded OpenSQL data types and a discussion of data type conversion, see the Embedded SQL Companion Guide.
The embedded OpenSQL preprocessor is concerned only with host language variables that are declared to OpenSQL. Host language variables that are not declared to OpenSQL are invisible to the preprocessor and therefore can include data types that the preprocessor does not understand.
Last modified date: 08/28/2024