The BEGIN DECLARE SECTION statement (embedded SQL only) marks the beginning of a host variable declare section in an application
program.
Invocation
BEGIN DECLARE SECTION is not an executable statement. It can only be embedded in a host language.
Authorization
No special authorization is required.
Syntax
BEGIN DECLARE SECTION
Description
BEGIN DECLARE SECTION may be used in an application program to mark the beginning of the section of code where host variables are declared. If a BEGIN DECLARE SECTION is used, the host variable declaration section must end with the END DECLARE SECTION statement.
When programming in C, or when the DECLARE or ANSI COBOL preprocessor directives are used, BEGIN and END DECLARE SECTION commands must surround the declarations for all host variables, to create host variable declaration blocks. As illustrated in the COBOL example below, a host variable declaration block can appear anywhere that the host language allows variable declarations:
The following rules are enforced by the precompiler, only if C is the host language, or if the DECLARE or ANSI COBOL precompiler option is specified:
Only if the DECLARE or the ANSI COBOL precompiler directive is specified or the host language is C, are host variable declaration sections required. Any source program, in any host language, can be made to conform to the SAA definition of SQL by specifying a declare section. If variable declaration sections are used when they are not required, all variables declared outside the declare section must have a name different from all variable names declared within the declare section.