Include Files--UNIX
The Embedded SQL include statement provides a means to include external files in your program's source code. Its syntax is:
exec sql include filename
filename
A single quoted string constant specifying a file name, or an external symbol that points to the file name. If you do not specify an extension to the filename, the default Fortran input file extension ".sf" is assumed.
This statement is normally used to include variable declarations, although it is not restricted to such use. For more details on the include statement, see the SQL Reference Guide.
The included file is preprocessed and an output file with the same name but with the default output extension ".f" (UNIX) or ".for" (VMS and Windows), is generated. You can override this default output extension with the -o.ext flag on the command line. In the original source file that specified the include statement, a new reference is made to the output file with the Fortran include statement. If you use the -o flag with no extension, an output file is not generated for the include statement.
If you use both the -o.ext and the -o flags, then the preprocessor generates the specified extension for the translated include statements in the program, but does not generate new output files for the statements.
For example, assume that no overriding output extension was explicitly given on the command line. The Embedded SQL statement:
exec sql include 'employee.dcl'
is preprocessed to the Fortran statement:
include 'employee.f'
and the "employee.dcl" file is translated into the Fortran file "employee.f".
As another example, assume that a source file called "inputfile" contains the following include statement:
exec sql include 'mydecls'
The name "mydecls" can be defined as a system environment variable pointing to the file "/usr/headers/myvars.sf". For example:
setenv mydecls "/usr/headers/myvars.sf"
Because the extension ".sf" is the default input extension for Embedded SQL include files, you do not need to specify it when defining a logical name for the file.
Assume now that "inputfile" is preprocessed with the command:
esqlf -o.hdr inputfile
The command line specifies ".hdr" as the output file extension for include files. As the file is preprocessed, the include statement shown earlier is translated into the Fortran statement:
include '/usr/headers/myvars.hdr'
and the Fortran file "/usr/headers/myvars.hdr" is generated as output for the original include file, "/usr/headers/myvars.sf".
You can also specify include files with a relative path. For example, if you preprocess the file "/dev/mysource/myfile.sf", the ESQL statement:
exec sql include '../headers/myvars.sf'
is preprocessed to the Fortran statement:
include '../headers/myvars.f'
and the Fortran file "/dev/headers/myvars.f" is generated as output for the original include file, "/dev/headers/myvars.sf".