5. Embedded SQL for Ada : Ada Variables and Data Types : Embedded SQL/Ada Declarations : Embedded SQL Variable Declaration Sections
 
Share this page                  
Embedded SQL Variable Declaration Sections
Embedded SQL statements use Ada variables to transfer data to and from the database or a form into the program. You must declare Ada variables and constants to Embedded SQL before using them in any Embedded SQL statements. Ada variables, types and constants are declared to Embedded SQL in a declaration section. This section has the following syntax:
exec sql begin declare section;
           Ada type and variable declarations
exec sql end declare section;
Note that placing a label in front of the exec sql end declare section statement causes a preprocessor syntax error.
Embedded SQL variable declarations are global to the program file from the point of declaration onwards. You can incorporate multiple declaration sections into a single program, as would be the case when a few different Ada procedures issue embedded statements using local variables. Each procedure can have its own declaration section. For a discussion of the declaration of variables that are local to Ada procedures, see The Scope of Variables (see page The Scope of Variables) in this chapter.