buggins / ddbc

DDBC is DB Connector for D language (similar to JDBC)
78 stars 45 forks source link

odbc driver doesn't support SQL_DECIMAL #82

Open the5avage opened 4 years ago

the5avage commented 4 years ago

Hi, when using the odbc driver with an Oracle database my program crashed with an exception ("Type 3 not supported"). I could fix this by adding a case to the switch statement in line: 922 of file drivers/odbcddbc.d:

case SQL_DECIMAL: return readValue!(char[]);

I'm not experienced with SQL (i want to use ddbc for a sql course at my university) so maybe i miss some subtle issue with this. It also works to convert it to double like this,

case SQL_DECIMAL: return readValue!double;

but in my case the decimal type is used to store user IDs and converting to a floating point type would make no sense...

SingingBush commented 4 years ago

DECIMAL can be various types depending on the precision that was used:

Precision Storage bytes
1 – 9 5
10-19 9
20-28 13
29-38 17

So it should probably attempt to convert to whichever number type the user is using and error if the data cannot convert correctly.