Embedded SQL statements in FORTRAN applications
You can include embedded
SQL statements in FORTRAN applications. Before you can use the SQL
statements, you must setup and enable your application to support
embedded SQL.
Embedded SQL statements in FORTRAN applications consist of the
following three elements:
- Correct FORTRAN Element Syntax
- Statement initializer
- EXEC SQL
- Statement string
- Any valid SQL statement with blanks as delimiters
- Statement terminator
- End of source line.
The end of the source line serves as the statement terminator. If the line is continued, the statement terminator will then be the end of the last continued line.
For example:
EXEC SQL SELECT COL INTO :hostvar FROM TABLE
The following rules apply to embedded SQL statements in FORTRAN
applications:
- Code SQL statements between columns 7 and 72 only.
- Use full-line FORTRAN comments, or SQL comments, but do not use the FORTRAN end-of-line comment '!' character in SQL statements. This comment character may be used elsewhere, including host variable declarations.
- Use blanks as delimiters when coding embedded SQL statements, even though FORTRAN statements do not require blanks as delimiters.
- Use only one SQL statement for each FORTRAN source line. Normal FORTRAN continuation rules apply for statements that require more than one source line. Do not split the EXEC SQL statement initializer between lines.
- SQL comments are allowed on any line that is part of an embedded
SQL statement. These comments are not allowed in dynamically executed
statements. The format for an SQL comment is a double dash (
--
), followed by a string of zero or more characters and terminated by a line end. - FORTRAN comments are allowed almost anywhere within an
embedded SQL statement. The exceptions are:
- Comments are not allowed between EXEC and SQL.
- Comments are not allowed in dynamically executed statements.
- The extension of using
!
to code a FORTRAN comment at the end of a line is not supported within an embedded SQL statement.
- Use exponential notation when specifying a real constant in SQL statements. The database manager interprets a string of digits with a decimal point in an SQL statement as a decimal constant, not a real constant.
- Statement numbers are not valid on SQL statements that precede the first executable FORTRAN statement. If an SQL statement has a statement number associated with it, the precompiler generates a labeled CONTINUE statement that directly precedes the SQL statement.
- Use host variables exactly as declared when referencing host variables within an SQL statement.
- Substitution of white space characters, such as end-of-line and
TAB characters, occurs as follows:
- When they occur outside quotation marks (but inside SQL statements), end-of-lines and TABs are substituted by a single space.
- When they occur inside quotation marks, the end-of-line characters disappear, provided the string is continued properly for a FORTRAN program. TABs are not modified.
Note that the actual characters used for end-of-line and TAB vary from platform to platform. For example, Windows-based platforms use the Carriage Return/Line Feed for end-of-line, whereas UNIX and Linux® based platforms use just a Line Feed.