In the declare section, you declare all host variables and indicator variables that are exchanged between the database instance and the application program in embedded SQL statements. You can use multiple declaration sections within an application program.
Observe the following rules:
· Start the declare section with EXEC SQL BEGIN DECLARE SECTION;.
· End the declare section with EXEC SQL BEGIN DECLARE SECTION;.
· Follow the permitted syntax for the declaration section.
· Observe the conventions for host variables and the rules for indicator variables.
· Use the data types permitted for the precompiler.
· You can use the memory classes typedef, static, extern or auto.
· You can specify declarations both outside of and within functions.
· As well as variable declarations, you can specify type definitions and parameter-free constant definitions (#define) for positive whole numbers in the declare section.
#define n(a)
(a+10) is not
permitted.
#define n
7is
permitted.
You can, for
example, use n as the length of an array
variable:
int array [n]
· Also specify array lengths for the memory class extern. These lengths must lie within the range of the corresponding external definitions.
To improve efficiency, only declare those variables in EXEC SQL declare sections that you are actually using as host variables in embedded SQL statements.
EXEC SQL BEGIN DECLARE SECTION;
char no [6];
char fname [8], lname [8];
EXEC SQL END DECLARE SECTION;