Was this helpful?
Include File Processing
The following sections describe include file processing for UNIX, VMS, and Windows.
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".
Include Files – VMS
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 a logical name 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 ".for" 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. This is useful for program libraries that use MMS dependencies.
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.for'
and the employee.dcl file is translated into the Fortran file "employee.for".
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 logical name pointing to the file "dra1:[headers]myvars.sf" by means of the following command at the system level:
define mydecls dra1:[headers]myvars
Because the extension ".sf" is the default input extension for Embedded SQL include files, it does not need to be specified 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 'dra1:[headers]myvars.hdr'
and the Fortran file "dra1:[headers]myvars.hdr" is generated as output for the original include file, "dra1:[headers]myvars.sf".
You can also specify include files with a relative path. For example, if you preprocess the file "dra1:[mysource]myfile.sf", the Embedded SQL statement:
exec sql include '[-.headers]myvars.sf'
is preprocessed to the Fortran statement:
include '[-.headers]myvars.for'
and the Fortran file "dra1:[headers]myvars.for" is generated as output for the original include file, "dra1:[headers]myvars.sf".
Include Files – Windows
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 a logical name 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 ".for" is generated. You can override this default output extension with the -o.ext flag on the command line. Within 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.for'
and the employee.dcl file is translated into the Fortran file "employee.for".
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 logical name pointing to the file "c:\usr\header\myvars.for" by means of the following command at the system level:
set mydecls=c:\usr\header\myvars
Because the extension ".for" is the default input extension for Embedded SQL include files, it does not need to be specified 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 'c:\usr\header\myvars.hdr'
and the Fortran file "c:\usr\header\myvars.hdr" is generated as output for the original include file, "c:\usr\header\myvars.for".
You can also specify include files with a relative path. For example, if you preprocess the file "c:\usr\mysource\myfile.sf", the Embedded SQL statement:
exec sql include '..\header\myvars'
is preprocessed to the Fortran statement:
include '..header\myvars.for'
and the Fortran file "..header\myvars.for" is generated as output for the original include file, "..header\myvars".
Source Code with Labels
Some Embedded SQL statements generate labels (statement numbers). The statement numbers 7000 through 12000 are reserved for the preprocessor. If you include a file containing statements that generate labels, be careful to include the file only once in a given Fortran scope. Otherwise, you may find that the compiler later complains that the generated labels are defined more than once in that scope.
The statements that generate labels are the Embedded SQL select statement and all the Embedded SQL/FORMS block-type statements, such as display and unloadtable.
Last modified date: 11/28/2023