Data Type Conversions
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, it implicitly specifies a data type conversion in its choice of the data
type of the application variable. For example, suppose a 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.
ODBC defines how data is converted between each SQL and C data type.
Basically, it supports all reasonable conversions, such as character to integer and
integer to float, and does not support ill-defined conversions, such as float to
date. Drivers are required to support all conversions for each SQL data type they
support. For a complete list of conversions between SQL and C data types, see “Converting Data from SQL to C Data Types” and “Converting Data from C to SQL Data Types” in Appendix D, “Data Types.”
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 defined to perform conversions in the data source. Because it is
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 SQLGetInfo. For more information about the CONVERT scalar function, see “Escape Sequences in ODBC” in Chapter 8, “SQL Statements” and Appendix E, “Scalar Functions.”