Was this helpful?
Coding Requirements for Embedded SQL Programs
The following sections describe coding requirements for writing Embedded SQL Programs.
Comments Embedded in Ada Output
Each Embedded SQL statement generates one comment and a few lines of Ada code. You may find that the preprocessor translates 50 lines of Embedded SQL into 200 lines of Ada. This can confuse the program developer trying to debug the original source code. To facilitate debugging, each group of Ada statements associated with a particular Embedded SQL statement is delimited by a comment corresponding to the original Embedded SQL source. Each comment is one line in length and informs the reader of the file name, line number, and type of statement in the original source file.
Embedded SQL Statements that Do Not Generate Code
The following Embedded SQL declarative statements do not generate any Ada code:
declare cursor
declare statement
declare table
whenever
These statements must not contain labels. Also, they must not be coded as the only statements in Ada constructs that do not allow empty statements. For example, coding a declare cursor statement as the only statement in an Ada if statement causes compiler errors:
if (using_database) then
        exec sql declare empcsr cursor for
                select ename from employee;
else
        put_line("You have not accessed the database.");
end if;
The preprocessor generates the code:
if (using_database) then
else
        put_line("You have not accessed the database.");
end if;
This is an illegal use of the Ada if-then-else statement.
Last modified date: 08/28/2024