Bug #29631 ADO recordsets not correctly populated by query containing decimal field types
Submitted: 8 Jul 2007 22:02 Modified: 18 Oct 2007 10:41
Reporter: John Wilson Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1 alpha OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any
Tags: ADO, decimal, ODBC, SQL_C_NUMERIC, truncated

[8 Jul 2007 22:02] John Wilson
Description:
An ADO recordset is not correctly populated by a query including DECIMAL field types.

The value returned from the first decimal field is truncated at the decimal point with subsequent fields in the query returning empty or 0.

Confirmed using ODBC driver 5.00.11 against a 5.0.42 & 4.1.6 database

Can also confirm that driver 3.51.16 works correctly in this respect with a 5.0.42 & 4.1.6 database.

How to repeat:
CREATE TABLE `test_table` (`f1` char(10) , `f2` char(10),`f3` decimal(3,1),`f4` decimal(3,1),`f5` char(10));
INSERT INTO test_table VALUES("AAAA","BBBB",21.5,22.5,"CCCC");

VB Script code:
===============

Option Explicit
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Dim objConn, objRS
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "DSN=my_dsn"
Set objRS = CreateObject("ADODB.RecordSet")
objRS.Open "SELECT * FROM test_table", objConn, adOpenForwardOnly,adLockReadOnly
WScript.Echo objRS(0) & "," & _
             objRS(1) & "," & _
             objRS(2) & "," & _
             objRS(3) & "," & _
             objRS(4)

Query should return:    AAAA,BBBB,21.5,22.5,CCCC
Query actually returns: AAAA,BBBB,21,0,
[8 Jul 2007 22:14] John Wilson
Using MDAC 2.8 SP1 on Windows XP SP2, and ADO 2.8 (i.e. latest versions)
[12 Jul 2007 18:34] Tonci Grgin
John, thanks for concise test case. Verified as described.

Explanation: We are aware of some problems with SQL_NUMERIC_STRUCT in v5 which is probably causing problem you're seeing.
[13 Jul 2007 18:28] John Wilson
Thanks for your speedy review - glad you were able to reproduce the issue.

As a matter of interest, do you have an ETA yet on a v5 release of the Connector/ODBC driver which fixes the SQL_NUMERIC_STRUCT?  Any ETA on a gamma release of the v5 Connector/ODBC driver?
[17 Oct 2007 12:33] Tonci Grgin
John, we still need to add SQL_C_NUMERIC support to 5.1 but I don't think it will take too long as 3.51 works as expected.
[17 Oct 2007 12:34] Tonci Grgin
Test case

Attachment: 29631.vbs (application/octet-stream, text), 1.91 KiB.

[18 Oct 2007 10:41] Susanne Ebrecht
This is a duplicate of bug #3028
[29 Oct 2007 8:36] Susanne Ebrecht
This is a duplicate of bug #10128