ODBC 3.0 driver behavior
Behavioral changes refer to functionality that varies depending on the version of ODBC that is in use. The ODBC 2.0 and ODBC 3.0 drivers behave according to the setting of the SQL_ATTR_ODBC_VERSION environment attribute.
SQLAllocHandle()
or
the ODBC 2.0 function SQLAllocEnv()
.
The application can explicitly set by calls to SQLSetEnvAttr()
.
- ODBC 3.0 applications
first call
SQLAllocHandle()
to get the environmental handle. The ODBC 3.0 driver implicitly sets SQL_ATTR_ODBC_VERSION = SQL_OV_ODBC3. This setting ensures that ODBC 3.0 applications get ODBC 3.0 behavior.An ODBC 3.0 application should not invoke
SQLAllocHandle()
and then callSQLAllocEnv()
. Doing so implicitly resets the application to ODBC 2.0 behavior. To avoid resetting an application to ODBC 2.0 behavior, ODBC 3.0 applications should always useSQLAllocHandle()
to manage environment handles. - ODBC 2.0 applications
first call
SQLAllocEnv()
to get the environmental handle. The ODBC 2.0 driver implicitly sets SQL_ATTR_ODBC_VERSION = SQL_OV_ODBC2. This setting ensures that ODBC 2.0 applications get ODBC 2.0 behavior.
An application can verify the ODBC version setting by calling SQLGetEnvAttr()
for
attribute SQL_ATTR_ODBC_VERSION. An application can explicitly set
the ODBC version setting by calling SQLSetEnvAttr()
for
attribute SQL_ATTR_ODBC_VERSION.
Forward compatibility does not affect ODBC 2.0 applications
that were compiled using the previous ODBC 2.0driver
header files, or ODBC 2.0 applications
that are recompiled using the new ODBC 3.0 header
files. These applications can continue executing as ODBC 2.0 applications
on the ODBC 3.0 driver.
These ODBC 2.0 applications
need not call SQLSetEnvAttr()
. As stated above, when
the existing ODBC 2.0 application
calls SQLAllocEnv()
(ODBC 2.0 API
to allocate environment handle), the ODBC 3.0 driver
will implicitly set SQL_ATTR_ODBC_VERSION = SQL_OV_ODBC2. This will
ensure ODBC 2.0 driver
behavior when using the ODBC 3.0 driver.