(Contents)(Previous)(Next)

The Declare Section

The declare section defines an interface for the interchange of values between the database system and the program. All the host variables and indicators to be used in SQL statements are made known to the precompiler in this interface.

The declare section begins with the SQL statement 'exec sql begin declare section' and ends with 'exec sql end declare section'.

This area may be repeated within the program.

The basic data types 'struct' and, if defined in a declare section, type names, are permitted. As storage classes, 'typedef', 'static', 'extern', and 'auto' may be specified. Declarations may be made outside functions as well as within functions. Declarators may contain one pointer declarator and up to four array declarators. Arrays of pointers are valid, but not pointers to arrays. If character pointers are used as SQL parameters, the precompiler cannot check the lengths and therefore returns a warning. At runtime, the character pointer must point to a character string delimited by zero. The array boundaries in declarators must also be specified for the storage class 'extern'; in this case, they must lie within the range of the corresponding external definitions.

Besides declarations, a declare section may contain type definitions and #define lines (constant definitions) without parameters for positive integers. The names defined hereby can be specified as array boundaries.

The parts that are to be analyzed by the precompiler (declare section, SQL statements) must not be components of #include files, but must be specified in the source text or in 'exec sql include' files.

For efficiency reasons, it is advisable to include only data in the declare section that will actually be used as host variables.

The syntax allowed within the declare section is described in Appendix 1: Syntax of the Declare Section.


(Contents)(Previous)(Next)