![]() |
![]() |
ALLBASE/SQL FORTRAN Application Programming Guide: HP 9000 Computer Systems > Chapter 1 Getting Started with ALLBASE/SQL Programming in FORTRAN![]() The ALLBASE/SQL FORTRAN Preprocessor |
|
The FORTRAN preprocessor that is part of ALLBASE/SQL is specifically for FORTRAN 77 programs. Although the preprocessor ignores FORTRAN statements in your source code, it generates FORTRAN statements, based on embedded SQL commands. Figure 1-3 “Preprocess-Time Events” summarizes the four main preprocess-time events:
The FORTRAN preprocessor scans the source code for SQL commands. If the syntax of an SQL command is valid, the preprocessor converts the command to compilable FORTRAN statements that call ALLBASE/SQL external procedures at runtime. During preprocessing, for example, the SQL command:
is converted into the following modified source code statements. The converted statements are shown in the coded statements below. The shaded areas show where the original code is commented out and the preprocessor generated code is added.
The embedded SELECT command has been converted into a FORTRAN comment, and FORTRAN statements that enable ALLBASE/SQL to execute the SELECT command at runtime have been inserted. The names that appear in the inserted FORTRAN code identify variables used by the ALLBASE/SQL external procedures; in this example, the names identify variables used by the SQLXFE external procedure. Some of these variables are derived from host variables. As shown in the embedded SELECT command above, you precede a host variable with a colon when you use it in SQL commands:
Type declarations used by preprocessor generated code are defined and initialized in the include file the preprocessor creates. The name of the include file is derived from the preprocessor's output file name followed by a period and the suffix .sqlv; for example ModifiedSourceFileName.sqlv. The preprocessor inserts INCLUDE statements that reference this file in each program unit of the modified source code after the host variable declarations. Even if you do not declare host variables you must still include the EXEC SQL BEGIN DECLARE SECTION and EXEC SQL END DECLARE SECTION commands in order for the preprocessor to create and insert an include file with this syntax:
When you invoke the preprocessor, you name an ALLBASE/SQL DBEnvironment. The preprocessor starts a DBE session for that DBEnvironment when preprocessing begins and terminates that session when preprocessing ends. When the preprocessor encounters a syntactically correct SQL command, it creates a section and stores that section in the system catalog of the DBEnvironment being accessed. An ALLBASE/SQL section is a group of stored ALLBASE/SQL instructions for executing one SQL command. All sections created during a preprocessing session constitute a module. The preprocessor derives the name of the module from the PROGRAM statement or subroutine name unless you supply a different name when you invoke the preprocessor:
When the preprocessor terminates its DBEnvironment session, it issues a COMMIT WORK command if it encountered no errors. Created sections are stored in the system catalog and associated with the module name. |