DB2 Version 9.7 for Linux, UNIX, and Windows

Supported SQL data types in FORTRAN embedded SQL applications

Certain predefined FORTRAN data types correspond to DB2® database column types. Only these FORTRAN data types can be declared as host variables.

The following table shows the FORTRAN equivalent of each column type. When the precompiler finds a host variable declaration, it determines the appropriate SQL type value. The database manager uses this value to convert the data exchanged between the application and itself.

Table 1. SQL Data Types Mapped to FORTRAN Declarations
SQL Column Type1 FORTRAN Data Type SQL Column Type Description

SMALLINT
(500 or 501)

INTEGER*2 16-bit, signed integer

INTEGER
(496 or 497)

INTEGER*4 32-bit, signed integer

REAL2
(480 or 481)

REAL*4 Single precision floating point

DOUBLE3
(480 or 481)

REAL*8 Double precision floating point

DECIMAL(p,s)
(484 or 485)

No exact equivalent; use REAL*8 Packed decimal

CHAR(n)
(452 or 453)

CHARACTER*n Fixed-length character string of length n where n is from 1 to 254

VARCHAR(n)
(448 or 449)

SQL TYPE IS VARCHAR(n) where n is from 1 to 32 672 Variable-length character string

LONG VARCHAR5
(456 or 457)

SQL TYPE IS VARCHAR(n) where n is from 32 673 to 32 700 Long variable-length character string

CLOB(n)
(408 or 409)

SQL TYPE IS CLOB (n) where n is from 1 to 2 147 483 647 Large object variable-length character string

CLOB locator variable4
(964 or 965)

SQL TYPE IS CLOB_LOCATOR Identifies CLOB entities residing on the server

CLOB file reference variable4
(920 or 921)

SQL TYPE IS CLOB_FILE Descriptor for file containing CLOB data

BLOB(n)
(404 or 405)

SQL TYPE IS BLOB(n) where n is from 1 to 2 147 483 647 Large object variable-length binary string

BLOB locator variable4
(960 or 961)

SQL TYPE IS BLOB_LOCATOR Identifies BLOB entities on the server

BLOB file reference variable4
(916 or 917)

SQL TYPE IS BLOB_FILE Descriptor for the file containing BLOB data

DATE
(384 or 385)

CHARACTER*10 10-byte character string

TIME
(388 or 389)

CHARACTER*8 8-byte character string

TIMESTAMP(p)
(392 or 393)

CHARACTER*19 to CHARACTER*32 19 to 32 byte character string

XML
(988 or 989)

SQL_TYP_XML

There is no XML support for FORTRAN; applications are able to get the describe type back but will not be able to make use of it.
Note:
  1. The first number under SQL Column Type indicates that an indicator variable is not provided, and the second number indicates that an indicator variable is provided. An indicator variable is needed to indicate NULL values, or to hold the length of a truncated string. These are the values that will be displayed in the SQLTYPE field of the SQLDA for these data types.
  2. FLOAT(n) where 0 < n < 25 is a synonym for REAL. The difference between REAL and DOUBLE in the SQLDA is the length value (4 or 8).
  3. The following SQL types are synonyms for DOUBLE:
    • FLOAT
    • FLOAT(n) where 24 < n < 54 is a synonym for DOUBLE.
    • DOUBLE PRECISION
  4. This is not a column type but a host variable type.
  5. The LONG VARCHAR data type is deprecated, not recommended, and might be removed in a future release. Choose the CLOB data type instead.
The following is an additional rule for supported FORTRAN data types:
  • You can define dynamic SQL statements longer than 254 characters by using VARCHAR, or CLOB host variables.