Previous Topic: Host VariablesNext Topic: INCLUDE TABLE Directive


SQL Declare Sections

In SQL Standard, you define host variables within an SQL declare section. You begin and end an SQL declare section with these statements:

EXEC SQL
  BEGIN DECLARE SECTION
END-EXEC.
 .
 .
 .
EXEC SQL
  END DECLARE SECTION
END-EXEC.

A CA IDMS extension of the SQL standard allows you to continue an SQL declaration section statement on the following line after any keyword.

What You Can Do

You can include any number of host variable declarations in an SQL declare section. You can include any number of SQL declare sections in a single application program.

Host Variable Declaration Example

In this example, the SQL declare section defines host variables, including one indicator variable, using standard COBOL data declarations.

WORKING-STORAGE SECTION.
 .
 .
 .
 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
   01  EMP-ID           PIC S9(8)     USAGE COMP.
   01  EMP-LNAME        PIC X(20).
   01  SALARY-AMOUNT    PIC S9(6)V(2) USAGE COMP-3.
   01  PROMO-DATE       PIC X(10).
   01  PROMO-DATE-I     PIC S9(4)     USAGE COMP.
 EXEC SQL END DECLARE SECTION END-EXEC.