Include files for FORTRAN embedded SQL applications

The host-language-specific include files for FORTRAN have the file extension .f on UNIX and Linux® operating systems, and .for on Windows operating systems. There are two methods for including files: the EXEC SQL INCLUDE statement and the FORTRAN INCLUDE statement. The precompiler ignores FORTRAN INCLUDE statements, and only process files included with the EXEC SQL statement. To locate the INCLUDE file, the Db2® FORTRAN precompiler searches the current directory first, and then the directories specified by the DB2INCLUDE environment variable.
Consider the following examples:
  • EXEC SQL INCLUDE payroll

    If the file specified in the INCLUDE statement is not enclosed in quotation marks, as shown previously, the precompiler searches for payroll.sqf, then payroll.f (payroll.for on Windows operating systems) in each directory in which it looks.

  • EXEC SQL INCLUDE 'pay/payroll.f'

    If the file name is enclosed in quotation marks, as shown previously, no extension is added to the name. (For Windows operating systems, the file would be specified as 'pay\payroll.for'.)

    If the file name in quotation marks does not contain an absolute path, then the contents of DB2INCLUDE are used to search for the file, prepended to whatever path is specified in the INCLUDE file name. For example, with Db2 for UNIX and Linux operating systems, if DB2INCLUDE is set to '/disk2:myfiles/fortran', the precompiler searches for './pay/payroll.f', then '/disk2/pay/payroll.f', and finally './myfiles/cobol/pay/payroll.f'. The path where the file is actually found is displayed in the precompiler messages. On Windows operating systems, substitute back slashes (\) for the forward slashes, and substitute 'for' for the 'f' extension in the previously shown example.

Note: The setting of DB2INCLUDE is cached by the Db2 command line processor. To change the setting of DB2INCLUDE after any CLP commands have been issued, enter the TERMINATE command, then reconnect to the database and precompile.

32-bit FORTRAN header files required for Db2 database application development, previously found in $INSTHOME/sqllib/include are now found in $INSTHOME/sqllib/include32.

In Version 8.1, these files were found in the $INSTDIR/sqllib/include directory which was a symbolic link to one of the following directories: $DB2DIR/include or $DB2DIR/include64 depending on whether or not it was a 32-bit instance or a 64-bit instance.

In Version 9.1, $DB2DIR/include will contain all the include files (32-bit and 64-bit), and $DB2DIR/include32 will contain 32-bit FORTRAN files only and a README file to indicate that 32-bit include files are the same as the 64-bit ones with the exception of FORTRAN.

The $DB2DIR/include32 directory will only exist on AIX®, HP-PA, and HP-IPF.

You can use the following FORTRAN include files in your applications.

SQLCA (sqlca_cn.f, sqlca_cs.f)
This file defines the SQL Communication Area (SQLCA) structure. The SQLCA contains variables that are used by the database manager to provide an application with error information about the execution of SQL statements and API calls.

Two SQLCA files are provided for FORTRAN applications. The default, sqlca_cs.f, defines the SQLCA structure in an IBM® SQL compatible format. The sqlca_cn.f file, precompiled with the SQLCA NONE option, defines the SQLCA structure for better performance.

SQLCA_92 (sqlca_92.f)
This file contains a FIPS SQL92 Entry Level compliant version of the SQL Communications Area (SQLCA) structure. This file should be included in place of either the sqlca_cn.f or the sqlca_cs.f files when writing Db2 applications that conform to the FIPS SQL92 Entry Level standard. The sqlca_92.f file is automatically included by the Db2 precompiler when the LANGLEVEL precompiler option is set to SQL92E.
SQLCODES (sqlcodes.f)
This file defines constants for the SQLCODE field of the SQLCA structure.
SQLDA (sqldact.f)
This file defines the SQL Descriptor Area (SQLDA) structure. The SQLDA is used to pass data between an application and the database manager.
SQLEAU (sqleau.f)
This file contains constant and structure definitions required for the Db2 security audit APIs. If you use these APIs, you need to include this file in your program. This file also contains constant and keyword value definitions for fields in the audit trail record. These definitions can be used by external or vendor audit trail extract programs.
SQLE819A (sqle819a.f)
If the code page of the database is 819 (ISO Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 500 (EBCDIC International) binary collation. This file is used by the CREATE DATABASE API.
SQLE819B (sqle819b.f)
If the code page of the database is 819 (ISO Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 037 (EBCDIC US English) binary collation. This file is used by the CREATE DATABASE API.
SQLE850A (sqle850a.f)
If the code page of the database is 850 (ASCII Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 500 (EBCDIC International) binary collation. This file is used by the CREATE DATABASE API.
SQLE850B (sqle850b.f)
If the code page of the database is 850 (ASCII Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 037 (EBCDIC US English) binary collation. This file is used by the CREATE DATABASE API.
SQLE932A (sqle932a.f)
If the code page of the database is 932 (ASCII Japanese), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 5035 (EBCDIC Japanese) binary collation. This file is used by the CREATE DATABASE API.
SQLE932B (sqle932b.f)
If the code page of the database is 932 (ASCII Japanese), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 5026 (EBCDIC Japanese) binary collation. This file is used by the CREATE DATABASE API.
SQL1252A (sql1252a.f)
If the code page of the database is 1252 (Windows Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 500 (EBCDIC International) binary collation. This file is used by the CREATE DATABASE API.
SQL1252B (sql1252b.f)
If the code page of the database is 1252 (Windows Latin-1), this sequence sorts character strings that are not FOR BIT DATA according to the host CCSID 037 (EBCDIC US English) binary collation. This file is used by the CREATE DATABASE API.
SQLSTATE (sqlstate.f)
This file defines constants for the SQLSTATE field of the SQLCA structure.
SQLUDF (sqludf.f)
This file defines constants and interface structures for writing user-defined functions (UDFs).