SQL$HELP_OLD72.HLB  —  BEGIN_DECLARE
    Delimits the beginning of a host language variable declaration
    section in a precompiled program.

1  –  Environment

    You can use the BEGIN DECLARE statement embedded in host language
    programs to be precompiled.

2  –  Format

  EXEC SQL --> BEGIN DECLARE SECTION --> ; ---+
  +-------------------------------------------+
  +-+-> <host language variable declaration> -+-+
    +---------<-------------------------------+ |
  +---------------------------------------------+
  +-> EXEC SQL --> END DECLARE SECTION --> ;

3  –  Arguments

3.1  –  BEGIN_DECLARE_SECTION

    Delimits the beginning of host language variable declarations.

3.2  –  END_DECLARE_SECTION

    Delimits the end of host language variable declarations.

3.3  –  ;_(semicolon)

    Terminates the BEGIN DECLARE and END DECLARE statements.

    Which terminator you should use depends on the language in which
    you are embedding the host language variable. The following table
    shows which terminator to use.

                         Required SQL Terminator

                                        END
                        BEGIN DECLARE   DECLARE
    Host Language       Statement       Statement

    COBOL               END-EXEC        END-EXEC
    FORTRAN             None required   None
                                        required
    Ada, C, Pascal, or  ; (semicolon)   ; (semi-
    PL/I                                colon)

3.4  –  host_language_variable_declaration

    A variable declaration embedded in a program.

    See the Parameters HELP topic for full details on host language
    variable definitions.

4  –  Example

    Example 1: Declaring a host language variable within BEGIN . . .
    END DECLARE statements

    The following example shows portions of a Pascal program. The
    first part of the example declares the host language variable
    LNAME within the BEGIN DECLARE and END DECLARE statements. The
    semicolon is necessary as a terminator because the language is
    Pascal.

    The second part of the example shows a singleton SELECT statement
    that specifies a one-row result table. The statement assigns
    the value in the row to the previously declared host language
    variable LNAME.

    EXEC SQL BEGIN DECLARE SECTION;
      LNAME: packed array [1..20] of char;
    EXEC SQL END DECLARE SECTION;
    .
    .
    .

    EXEC SQL
    SELECT FIRST_NAME
       INTO :LNAME
       FROM EMPLOYEES
       WHERE EMPLOYEE_ID = "00164";
Close Help