Scalable Database Server, HiRDB Version 8 SQL Reference

[Contents][Index][Back][Next]

BEGIN DECLARE SECTION (Declare beginning of embedded SQL)

Function

The BEGIN DECLARE SECTION declares the beginning of an embedded SQL declare section. Embedded variables and indicator variables used in the SQL must be specified in the embedded SQL declare section.

Format

BEGIN DECLARE SECTION

Common rules

  1. The end of an embedded SQL declare section is denoted by specifying an END DECLARE SECTION (declaring the end of an embedded SQL).
  2. All embedded variables and indicator variables used in the SQL must be declared in the embedded SQL declare section.
  3. Any number of embedded SQL declare sections (including no embedded SQL begin declare sections) can be specified in an embedded UAP.
  4. Only the declaration of variables can be specified in an embedded SQL declare section. However, embedded SQL declare sections that do not contain any declarations of variables can be specified.

Examples

Declare embedded variables used in an SQL:

C language
EXEC SQL BEGIN DECLARE SECTION;
   char XPCODE[5];
   char XPNAME[21];
   char XCOLOR[11];
   long XPRICE;
   long XSQUANTITY;
EXEC SQL END DECLARE SECTION;

COBOL language
   EXEC SQL
      BEGIN DECLARE SECTION
   END-EXEC.
77 XPCODE     PIC X(4).
77 XPNAME     PIC X(20).
77 XCOLOR     PIC X(10).
77 XPRICE     PIC S9(9) COMP.
77 XSQUANTITY PIC S9(9) COMP.
   EXEC SQL
       END DECLARE SECTION
   END-EXEC.