Contents|Index|Previous|Next

Declaring the Applications ODBC Version

Before an application allocates a connection, it must set the SQL_ATTR_ ODBC_VERSION environment attribute. This attribute states that the application follows the ODBC 2.x or ODBC 3.0 specification when using the following items:

odbc00090000.gif SQLSTATEs. Many SQLSTATE values are different in ODBC 2.x and ODBC 3.0.

odbc00090000.gif Date, Time, and Timestamp Type Identifiers. The following table shows the type identifiers for date, time, and timestamp data in ODBC 2.x and ODBC 3.0.

ODBC 2.x
ODBC 3.0



SQL Type Identifiers

SQL_DATE
SQL_TYPE_DATE
SQL_TIME
SQL_TYPE_TIME
SQL_TIMESTAMP
SQL_TYPE_TIMESTAMP
C Type Identifiers

SQL_C_DATE
SQL_C_TYPE_DATE
SQL_C_TIME
SQL_C_TYPE_TIME
SQL_C_TIMESTAMP
SQL_C_TYPE_TIMESTAMP

odbc00090000.gif
CatalogName Argument in SQLTables. In ODBC 2.x, the wild card characters (% and _) in the CatalogName argument are treated literally. In ODBC 3.0, they are treated as wild cards. Thus, an application that follows the ODBC 2.x specification cannot use these as wild cards and does not escape them when using them as literals. An application that follows the ODBC 3.0 specification can use these as wild cards or escape them and use them as literals. For more information, see Arguments in Catalog Functions in Chapter 7, Catalog Functions.

The ODBC 3.0 Driver Manager and ODBC 3.0 drivers check the version of the ODBC specification to which an application is written and respond accordingly. For example, if the application follows the ODBC 2.x specification and calls SQLExecute before calling SQLPrepare, the ODBC 3.0 Driver Manager returns SQLSTATE S1010 (Function sequence error). If the application follows the ODBC 3.0 specification, the Driver Manager returns SQLSTATE HY010 (Function sequence error). For more information, see Backward Compatibility and Standards Compliance in Chapter 17, Programming Considerations.

Important Applications that follow the ODBC 3.0 specification must use conditional code to avoid using functionality new to ODBC 3.0 when working with ODBC 2.x drivers. ODBC 2.x drivers do not support functionality new to ODBC 3.0 just because the application declares that it follows the ODBC 3.0 specification. Furthermore, ODBC 3.0 drivers do not cease to support functionality new to ODBC 3.0 just because the application declares that it follows the ODBC 2.x specification.