Progress
Embedded SQL-92
Guide and Reference
Defining Variables in a DECLARE SECTION
This section describes the DECLARE SECTION, and illustrates ESQL executable statements in examples. See the "Types of Executable Statements" section for more information on executable statements. This section also includes information on host variables and indicator variables, and how to use them in the DECLARE SECTION, in C Language statements, and in ESQL executable statements.
The ESQL precompiler is a tool that parses ESQL executable statements and translates them into C Language statements. ESQL does not allow the use of C-language defined variables in ESQL executable statements. The precompiler requires a DECLARE SECTION for declarations of any variables you use in ESQL executable statements.
In an ESQL source program, the DECLARE SECTION must precede any other ESQL constructs. Only C Language statements can precede the DECLARE SECTION. The variables defined in the DECLARE SECTION can be declared as local variables or global variables.
NOTE: The data types in the DECLARE section are SQL data types and C/C++ data types. Some, but not all, of the C/C++ data types are defined as synonyms for the corresponding SQL data types. In particular, ’int’ is not allowed.The following code fragment shows how to mark the beginning and end of a DECLARE SECTION and how to define variables:
The variables you declare in the DECLARE SECTION are called host variables and indicator variables. Table 3–1 lists the host variables defined in the DECLARE SECTION of this example. The code fragment uses the convention of ending each variable name with “_v” for variable name:
The ESQL precompiler generates the corresponding C Language declarations for these variables. The application program has access to these variables in C Language statements. The following sections provide more detail about host variables, indicator variables, and how to use them.
NOTE: The ESQL precompiler does not check for or generate messages about unused variables in the DECLARE SECTION.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |