Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


ESQL in FORTRAN Programs


Mimer SQL supports ESQL for ANSI FORTRAN-90 fixed format.

Source statements must be provided as fixed format, 80 byte records.

SQL Statement Format

The following sections discuss the SQL statement format.

Statement Delimiters

The leading delimiter EXEC SQL identifies SQL statements. The end of an SQL statement is marked by the end of the line when the following line does not begin with a continuation character. The FORTRAN-90 statement delimiter ; can also be used.

Example:
 EXEC SQL DELETE FROM countries

Margins

Statements (including delimiters) may be written anywhere between positions 7 and 72 inclusive.

Line Continuation

Line continuation rules for SQL statements are the same as those for ordinary FORTRAN statements. The continuation character is any character except space and 0 (zero) in position 6. The FORTRAN limitation of a maximum of 19 continuation lines per statement does not apply within SQL statements.

For a string constant, a white-space character (ASCII HEX-values 09 - 0D, or 20, i.e. <TAB>, <LF>, <VT>, <FF>, <CR> or <SP>), can be used to join two or more substrings. Each substring must be separately enclosed in delimiters.

Examples:
      EXEC SQL SELECT CODE, CURRENCY
 +                FROM MIMER_STORE.CURRENCIES
 +                WHERE CODE LIKE :CODE
 
      EXEC SQL COMMENT ON TABLE CURRENCIES IS
 +                        'Holds currency'<CR>
 +                        ' details'

Statement Numbers

Any labeled SQL statement in the source code will generate a CONTINUE statement during preprocessing. Declarative SQL statements used before the first executable SQL statement should not be labeled.

Comments

Comment lines, marked by * or C in position 1, may be written within SQL statements. The whole line following a comment mark is treated as a comment, and the following line must either be another comment or follow the continuation rules given above.

Note: Lines that are completely blank are not treated as comments by the
ESQL/FORTRAN preprocessor. The absence of a continuation character indicates the end of the previous statement, and a completely blank line may be used to structure comments in the output from the preprocessor. See Preprocessor Output Format for details.

FORTRAN-90 style comments may also be used, marked by the ! character (the text between the ! and the end-of-line is treated as a comment).

Debugging lines (marked with a D in position 1) are treated as comments by the preprocessor.

Host Variables

The following sections discuss declarations, SQL data type correspondence, value assignments, preprocessor output format and scope.

Declarations

Host variables used in SQL statements must be declared within the SQL DECLARE SECTION, delimited by the statements BEGIN DECLARE SECTION and END DECLARE SECTION.

Variables declared within the SQL DECLARE SECTION must conform to the following rules in order to be recognized by the SQL preprocessor:

A syntax diagram showing the variable declarations recognized by the ESQL/FORTRAN preprocessor is given below:



The data type declaration must be separated from the variable name by at least one space (which is not required in FORTRAN declarations outside the SQL DECLARE SECTION).

Thus the declaration:

     INTEGER*2A
 

is not recognized. The required formulation is:

     INTEGER*2 A
 

Lists of variables following a single default data type declaration are accepted. Any declarations in a list that are not valid in SQL contexts are ignored by the preprocessor. Thus, the following statement declares variables A and D as INTEGER*4 and B as INTEGER*2 for use in SQL statements, while the array C is ignored:

     INTEGER*4    A, B*2, C(10), D

SQL Data Type Correspondence

Valid host data types are listed below for each of the data types used in SQL statements.

SQL data type
FORTRAN data declaration
 SMALLINT
 INTEGER
 BIGINT
 INTEGER*2
 INTEGER*4
 INTEGER*8
 DECIMAL
 NUMERIC
 REAL*4
 FLOAT
 DOUBLE
 REAL
 REAL*8
 DOUBLE PRECISION
 CHARACTER
 VARCHAR
 DATETIME
 INTERVAL
 CHARACTER*n

The following additional points should be noted:

Value Assignments

The general rules for conversion of values between compatible but different data types, see of the Mimer SQL Reference Manual, apply to the transfer of data between the database and host variables, with the data type correspondence as given in the table above.

Preprocessor Output Format

Output from the ESQL/FORTRAN preprocessor retains SQL statements from the original source code as comments. The output follows the ANSI standard for record format, and should be compiled with a FORTRAN compiler set to accept ANSI standard. Comments within SQL statements are retained exactly as written.

Completely blank lines between SQL statements and following comments cause the preprocessor to write the comments after the generated SQL call. Otherwise comments immediately following SQL statements are output before the generated call. Debugging lines (using D in position 1) remain unchanged after preprocessing.

The preprocessed code is structured to reflect the structuring of the original source code.

Scope Rules

Host variables follows the same scope rules as ordinary variables in FORTRAN.

SQL descriptor names, cursor names and statement names must be unique within the compilation unit.

A compilation unit for FORTRAN is the same as a routine.


Mimer
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
info@mimer.se
Mimer SQL Documentation TOC PREV NEXT INDEX