PRB: Fractional Truncation of Numeric Data if You Use MSDASQL and Custom ODBC Driver (311432)



The information in this article applies to:

  • Microsoft OLE DB Provider for ODBC 2.0
  • ActiveX Data Objects (ADO) 2.1
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7

This article was previously published under Q311432

SYMPTOMS

If an ActiveX Data Objects (ADO) or OLE DB client tries to retrieve data from a bound numeric column with a forward-only cursor from a custom ODBC 3.x driver by using the Microsoft OLEDB Provider for ODBC Drivers (MSDASQL), you may receive the following SQL_SUCCESS_WITH INFO warning message when the client makes a call to SQLFetch:
DIAG [01004] [ Custom_ODBC_Driver] Fractional truncation
The ADO client can retrieve the data but no significant digits appear after the decimal. You can see this warning in the Open Database Connectivity (ODBC) trace logs, but not in the ADO client. The ADO client generally returns error messages only.

RESOLUTION

When you work with ADO clients and MSDASQL to retrieve numeric column data, the custom ODBC 3.x drivers need to support SQLExtendedFetch, or lower the ODBC conformance level to 2.x.

According to the ODBC Application Programming Interface (API) Reference, the Microsoft OLEDB Provider for ODBC Drivers (MSDASQL) is essentially a fully compliant 2.x ODBC client that supports some 3.x functionality. The API Reference states the following:
ODBC 3.x drivers should support SQLExtendedFetch if they want to work with ODBC 2.x applications that call SQLExtendedFetch.
				

STATUS

This behavior is by design.

MORE INFORMATION

For an ODBC version 3.x driver, a numeric column is bound to a SQL_C_NUMERIC C data type. Additionally, for a numeric column, the default Precision property is driver-defined whereas the default Scale property is 0 and is not driver-defined. If any default Precision or Scale is not appropriate for a numeric column, you can use the SQL_DESC_PRECISION and SQL_DESC_SCALE descriptors to set these properties appropriately.

If an ODBC version 3.x driver does not support SQLExtendedFetch, MSDASQL (which is basically a fully compliant ODBC 2.x client) creates an ODBC 2.x binding client that uses SQLFetch to retrieve the data. In general, an ODBC 2.x client that retrieves bound numeric data by using SQLFetch does not use the SQL_DESC_PRECISION and SQL_DESC_SCALE descriptors for numeric columns. Therefore, the default Precision (which is driver-defined) and default Scale (which is 0) properties are used to retrieve the data. Because the Scale property is 0, significant digits after the decimal point are not returned and the driver returns the "Fractional truncation" warning that is described in the "Symptoms" section.

If the ODBC 3.x driver supports SQLFetchScroll, non-forward-only cursors, and bookmarks, and the ADO client requests a recordset with non-forward-only cursors, MSDASQL can create an ODBC 3.x binding client to retrieve data. A binding client can retrieve numeric data that is bound to SQL_C_NUMERIC without causing fractional truncation by using SQLFetchScroll.

REFERENCES

For additional information, visit the following Microsoft Developer Network (MSDN) Web sites:

ODBC Provider Version Compliance Document
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/oledb/htm/odbcproviderversion_compliance.asp

ODBC API Reference for SQLExtendedFetch
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcsqlextendedfetch.asp

ODBC API Reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcodbc_api_reference.asp

Modification Type:MajorLast Reviewed:10/17/2003
Keywords:kbDatabase kbprb KB311432