END DECLARE SECTION

The END DECLARE SECTION statement marks the end of an SQL declare section.

Invocation

This statement can only be embedded in an application program. It is not an executable statement. It must not be specified in Java or REXX.

Authorization

None required.

Syntax

Read syntax diagram
>>-END DECLARE SECTION-----------------------------------------><

Description

The END DECLARE SECTION statement can be coded in the application program wherever declarations can appear in accordance with the rules of the host language. It is used to indicate the end of an SQL declare section. An SQL declare section starts with a BEGIN DECLARE SECTION statement described in BEGIN DECLARE SECTION.

The following rules are enforced by the precompiler only if the host language is C or the STDSQL(YES) precompiler option is specified:

  • A variable referred to in an SQL statement must be declared within an SQL declare section of the source program.
  • BEGIN DECLARE SECTION and END DECLARE SECTION statements must be paired and must not be nested.
  • SQL declare sections can contain only host variable declarations, SQL INCLUDE statements that include host variable declarations, or DECLARE VARIABLE statements.

Notes

SQL declare sections are only required if the STDSQL(YES) option is specified or the host language is C. However, SQL declare sections can be specified for any host language so that the source program can conform to IBM® SQL. If SQL declare sections are used, but not required, variables declared outside an SQL declare section should not have the same name as variables declared within an SQL declare section.

Example

  EXEC SQL BEGIN DECLARE SECTION;
 
   -- host variable declarations 
 
  EXEC SQL END DECLARE SECTION;