This problem was experienced against a DB2 RDBM on the
mainframe. According to the IBM DB2 manual "DB2 for OS/390 Version 5: SQL
Reference", chapter 3.7.3.5, the maximum precision of a
DECIMAL can be up to 31 digits.
This causes the OLE DB Provider
for DB2 to return a data type
DBTYPE_DECIMAL with a precision of 31 because it is defined that way on the
host. However, this value is larger than a
DECIMAL data type can be according to our OLEDB specification where the
maximum precision is supposed to be 29. The OLEDB specification states the
following:
DBTYPE_DECIMAL 0 to 28
DBTYPE_NUMERIC 0 to 38
DBTYPE_VARNUMERIC -128 to 127
Type indicator Maximum precision
DBTYPE_DECIMAL 29
DBTYPE_NUMERIC 38
DBTYPE_VARNUMERIC 255
See also the documentation at the following MSDN Web
site:
The hotfix that is described earlier in this article changed the
DBTYPE for all the decimal fields with a precision of greater than 28
from
DBTYPE_DECIMAL to
DBTYPE_NUMERIC.
IMPORTANT: Starting with IBM DB2 UDB version 8, fields that are described
as
NUMERIC and
DECIMAL are both being returned from DB2 UDB as type
DECIMAL. With the hotfix described in this article applied, this means
that the maximum precision of both
NUMERIC and
DECIMAL data types when using DB2 UDB version 8 or later is 28. This is
true only when using ADO Client side cursors. With the hotfix applied, if you
are using ADO Client side cursors and DB2 UDB version 8 and you try to access a
NUMERIC or
DECIMAL field with a precision larger than 28, you will receive the
following error:
Data descriptor mismatch. SQLSTATE:
HY000, SQLCODE: -292