Was this helpful?
Include File Processing
The Embedded SQL include statement provides a means to include external packages and source files in your program's source code. Its syntax is:
exec sql include filename;
where filename is a quoted string constant specifying a file name or a logical name that points to the file name. If you do not specify an extension to the file name (or to the file name pointed at by the logical name), the default Ada input file extension ".sa" is assumed.
This statement is used to include variable declarations or package specifications. For more details on the include statement, see the SQL Reference Guide.
How to Include Variable Declarations
If issued in a declaration section, the include statement can only be used to include variable declarations. The included file is preprocessed, and Ada output is generated into the parent file.
For example, a file called "employee.dcl" containing a record declaration generated by DCLGEN can be included into the source code as follows:
exec sql begin declare section;
       exec sql include 'employee.dcl';
    -- more declarations
exec sql end declare section;
The employee.dcl file is preprocessed into the parent output file.
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.
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.
Last modified date: 08/28/2024