Data type conversions

 

Data can be converted from one type to another at one of four times:

 

 

Any conversion that occurs when data is transferred from one application variable to another is outside the scope of this document.

 

When an application binds a variable to a result set column or statement parameter, the choice of the variable's type implicitly specifies a data type conversion. For example, suppose a resultset column contains integer data. If the application binds an integer variable to the column, it specifies that no conversion be done. If it binds a character variable to the column, it specifies that the data be converted from integer to character. The SQL data type is an integer, but the application uses the data as a character variable.

 

ODBC defines how data is converted between each SQL and Fortran data type. Basically, it supports all reasonable conversions, such as character to integer and integer to float. It does not support ill-defined conversions, such as float to date.

 

ODBC also defines a scalar function for converting data from one SQL data type to another. The CONVERT scalar function is mapped by the driver to the underlying scalar function or functions. These functions are defined to perform conversions in the data source. Because they are mapped to DBMS-specific functions, ODBC does not define how these conversions work or what conversions must be supported. An application discovers what conversions are supported by a particular driver and data source through the SQL_CONVERT options in f90SQLGetInfo. For more information on supported conversions see Appendix 3.