Section Declarations

From InterBase
Jump to: navigation, search

Go Up to Declaring Host Variables


Many SQL implementations expect host variables to be declared between BEGIN DECLARE SECTION and END DECLARE SECTION statements. For portability and compatibility, InterBase supports section declarations using the following syntax:

EXEC SQL
BEGIN DECLARE SECTION;
<hostvar>;
. . .
EXEC SQL
END DECLARE SECTION;

For example, the following C code fragment declares three host variables, empno, fname, and lname, within a section declaration:

EXEC SQL
BEGIN DECLARE SECTION;
int empno;
char fname[26];
char lname[26];
EXEC SQL
END DECLARE SECTION;

Additional host-language variables not used in SQL statements can be declared outside DECLARE SECTION statements.

Advance To: