Oracle 10.2 ODBC driver: SQLDescribeCol returns too small a precision for numeric expressions



Hello,

I hope this is the correct newsgroup to ask about the Oracle ODBC driver
but I didn't find any better place for this.

Short story: It seems that the Oracle 10.2 ODBC driver returns
wrong (too small) precision values for expressions computed in
SELECT statements.

Long story: I have an application that submits queries to an Oracle
database using the SQLExecDirect/SQLFetch functions. The query contains
both database columns and expressions, like

SELECT colname,
DECODE(col2,0,0,col1/col2)
FROM tablename
WHERE ...

After SQLExecDirect I'm calling SQLDescribeCol for each column and
expression in the query to determine the maximum size of the expected
result:

for(int ColId=...)
{
UCHAR ColName[50+1];
SWORD ColNameLen=0,SQLType=0,Scale=0,Null=0;
UDWORD Prec=0;
rc = SQLDescribeCol(hstmt,ColId,
ColName,sizeof(ColName),&ColNameLen,
&SQLType,&Prec,&Scale,&Null);
...
}

Then, I allocate a buffer of size Scale+Prec+2 bytes and call SQLBindCol
to tell ODBC about the buffer size and address. This has worked flawlessly
for years and across many versions of the Oracle server, client, and ODBC
driver.

Because there's a division, the computed expression has up to 16 digits
after the decimal point. This is fine since SQLDescribeCol returns a
precision of 38 so my buffer is large enough for the result.

Now, with the 10.2 ODBC driver, SQLDescribeCol returns a precision of 15
for that same expression. I thus allocate a buffer of 17 bytes, but
the expression returned by Oracle is 18 bytes long (one digit before the
decimal point, the decimal point itself, and 16 digits following). So,
the result doesn't fit into the buffer, and the query aborts with the
error "SQLSTATE=01004: [Oracle][ODBC]String data, right truncated".

The problem occurs with the Oracle ODBC drivers 10.2.0.1 and 10.2.0.3,
which seems to be the latest 10.2 driver available from Oracle. It
works fine with the 10.1.0.2 driver.

Is this a bug in the 10.2 ODBC driver, or am I doing something wrong?
In either case, what can be done about it?

My platform is Visual Studio 7.0 on Windows XP. The database version is
10.2.

Thanks for any help
W. Rösler
.



Relevant Pages

  • Re: Need help with Access 97 and Oracle 9i
    ... I'm trying to make the connection on the my local machine. ... discussed using ODBC driver to connect to Oracle. ... I found that the Microsoft ODBC Driver doesn't ... I'm looking for anything I can get; suggestions, recommendations, ...
    (microsoft.public.access.externaldata)
  • RE: ORACLE DRIVER
    ... The thing is that I'm using in a Linux machine. ... So is there any free Oracle ODBC driver for Linux? ... UnixODBC is a freeware but couldn't find any free Oracle Drivers. ...
    (perl.dbi.users)
  • Re: CA-Realia, SqlState -91, Odbc preprocessor and Oracle database
    ... Using Microsoft Odbc Driver for Oracle, the buffer size was 64K ...
    (comp.lang.cobol)
  • Re: Need help with Access 97 and Oracle 9i
    ... Not sure if our google results were the same. ... discussed using ODBC driver to connect to Oracle. ... I found that the Microsoft ODBC Driver doesn't ... I'm looking for anything I can get; suggestions, recommendations, required ...
    (microsoft.public.access.externaldata)
  • RE: SQLFetch() very slow with Oracle
    ... Based on my understanding, the problem is when calling the SQLFetchto ... fetch the data from Oracle database, you found Microsoft's ODBC driver is ... so much slower than the Oracle driver to complete the above operation. ... ODBC driver and Oracle driver just as you mentioned. ...
    (microsoft.public.vc.database)