Data types are the fundamental units used by DBMS to store and handle information. They are also the fundamental units to store information in application programs. When accessing data through ODBC, a programmer has to deal with two different sets of data, the driver's native data and the application native data. In ODBC jargon, these two data types are usually known as the SQL data types and the C data types. SQL data types are used in the data source, and C data types are used in C code in the application. Fortran programs using f90SQL use the Fortran data types defined in the f90SQL library.
Some functions in the ODBC-API expect specific data types. For example, some functions expect the application to pass a string of characters (or more exactly a pointer to a string of characters), or a 32-bit integer as parameters. In other cases, the ODBC-API expects the application to tell it what type of data it must use for an operation. To do this, ODBC defines a set of data type identifiers. ODBC uses integer values to identify data types. For example, the value 1 is used to identify the SQL character data type. To facilitate programming, these values are defined as named constants. Instead of using 1 to identify a SQL character type, you use the constant SQL_CHAR. Fortran data types are identified in the same fashion. The constant SQL_F_LONG is the identifier used for an application integer.
f90SQL defines kind parameters and structures that will facilitate declaring variables in your ODBC application. A kind parameter is a Fortran 90 attribute that is associated to a data declaration which indicates the number of bytes (and the numeric precision) the variable uses. For example, many Fortran compilers accept 1, 2, 4 and 8-bytes integer. When you declare an integer variable in Fortran, you can tell the compiler how many bytes you want it to be. For example, the following three declarations are equivalent and declare the 2-byte integer variable i:
integer*2 i
integer(kind=2) i
integer(2) i
The kinds defined in f90SQL make programming easier because the programmer does not need to remember whether, for example, an integer variable that will contain a handle should be stored in a 2, 4 or 8-byte integer. Instead, the programmer declares the variable as:
integer(SQLHANDLE_KIND) Hndl
SQLHANDLE_KIND is in fact a constant defined in module f90SQLConstants, and it has a value of 4. Thus, the previous declaration is creating an integer*4 variable.