5. Embedded SQL for Ada : Preprocessor Operation : Include File Processing : How to Include Package Specifications
 
Share this page                  
How to Include Package Specifications
If issued outside a declaration section, the include statement can only be used to include package specifications. The preprocessor reads the specified file, processing all variables declared in the package, and generates the Ada with and use clauses using the last component of the file name (excluding the file extension) as the package name. If the last component of the file name has a trailing underscore, as is standard in VAX/VMS Ada package specification files, then the preprocessor removes that trailing underscore in the generated context clauses. The preprocessor does not generate an output file, because it is assumed that the package specification has already been compiled.
Note:  Notes:
Each package must be in a separate source file.
Nothing but the package should be in that source file (no other variable declarations, etc).
There are no limitations on what can be in a package (you may define types, etc).
The following example demonstrates the include statement. Assume that the specification of package "employee" is in a employee_.sa file and that a procedure "empentry" is in the empentry.sa file:
Contents of employee_.sa:
package employee is
    exec sql begin declare section;
                ename:   String(1..20);
                eage:    Integer;
                esalary: Float;
    exec sql end declare section;
end employee;
Contents of empentry.sa:
exec sql include '[joe.neil.empfiles]employee_.sa';
procedure empentry is
begin
    -- Statements using variables in package
    -- "employee"
end empentry;
The Embedded SQL/Ada preprocessor modifies the include line to the Ada with and use clauses by extracting the last component of the file name:
with employee;    use employee;
The above two clauses appear in the empentry.ada output file. The preprocessor does not generate an output file for "employee_.sa," and the employee package must have already been compiled in order to compile the empentry.ada file.
Assuming that the employee_.sa and empentry.sa files appear as shown above, you should execute the following sequence of VMS commands in order to compile "empentry.ada":
esqla employee_.sa
esqla empentry.sa
ada employee_.ada
ada empentry.ada
You must still follow the Ada rules specifying the order of compilation. The Embedded SQL preprocessor does not affect these compilation rules.