Error Message: The decimal field precision is too small to accept the numeric you attempted to add.




Problem

Informix's DECIMAL type can hold both fixed-point and floating-point values.


The problem occurs with columns defined using the second and third forms above, i.e., when a DECIMAL column holds floating-point data. When Informix detects such a column, it reports the column's scale as 255. The maximum scale of a DECIMAL column holding fixed-point data is 32, so 255 indicates floating-point data. Our agent was detecting when scale = 255 and adjusting the scale to a more meaningful value for ODBC.

The issue was that the driver always mapped an Informix DECIMAL to the ODBC SQL type SQL_DECIMAL, and when scale=255 was detected, the driver adjusted the scale to match the column's precision. However the adjusted scale value was not always appropriate, which caused Access to balk. A column's scale can be retrieved through several ODBC functions: SQLDescribeCol(), SQLColAttributes(), SQLColumns(), and this fix applies to all of these calls.

Fix

The driver now maps:


Testing

Create and populate a test table —

CREATE TABLE bug5552 
   ( id INT, 
     d1 DECIMAL(5,2), 
     d2 DECIMAL(6), 
     d3 DECIMAL
   ) ;

INSERT INTO bug5552 
   VALUES (1, 321.12,    654.321,    654321.0987654321 ) 
   VALUES (2, 654.32,    65432.1,     6543210987654321 ) 
   VALUES (3,  92.37,  6.54321e6,  6.543210987654321e2 )
   VALUES (4, 987.65, 6.54321e41, 6.543210987654321e49 ) ;


These values were chosen to use the full precision of each column.

All of these values should be retrieved correctly from a linked table in Microsoft Access whether jetfix is on or off. Note that Microsoft Access fetches these columns into NUMBER columns, the precision of which varies depending on the underlying Field Size property; consequently, some values may be rounded.