LOB usage in ODBC applications

You can still access LOB columns from ODBC-compliant applications by setting the LongDataCompat configuration keyword in the initialization file, or by setting the SQL_ATTR_LONGDATA_COMPAT connection attribute using SQLSetConnectAttr().

Once this is done, CLI will map the ODBC long data types to the Db2® LOB data types.

Existing ODBC-compliant applications use SQL_LONGVARCHAR and SQL_LONGVARBINARY instead of the Db2 BLOB and CLOB data types. You can still access LOB columns from these ODBC-compliant applications by setting the LongDataCompat configuration keyword in the initialization file, or setting the SQL_ATTR_LONGDATA_COMPAT connection attribute using SQLSetConnectAttr(). Once this is done, CLI will map the ODBC long data types to the Db2 LOB data types. The LOBMaxColumnSize configuration keyword allows you to override the default COLUMN_SIZE for LOB data types.

When this mapping is in effect:
  • SQLGetTypeInfo() will return CLOB, BLOB and DBCLOB characteristics when called with SQL_LONGVARCHAR, SQL_LONGVARBINARY or SQL_LONGVARGRAPHIC.
  • The following functions will return SQL_LONGVARCHAR, SQL_LONGVARBINARY or SQL_LONGVARGRAPHIC when describing CLOB, BLOB or DBCLOB data types:
    • SQLColumns()
    • SQLSpecialColumns()
    • SQLDescribeCol()
    • SQLColAttribute()
    • SQLProcedureColumns()
  • LONG VARCHAR and LONG VARCHAR FOR BIT DATA will continue to be described as SQL_LONGVARCHAR and SQL_LONGVARBINARY.

The default setting for SQL_ATTR_LONGDATA_COMPAT is SQL_LD_COMPAT_NO; that is, mapping is not in effect.

With mapping in effect, ODBC applications can retrieve and input LOB data by using the SQLGetData(), SQLPutData() and related functions.