Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS 0.82 returning ODBC v2 values instead of ODBCv3 values

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: jklowden AT schemamania.org
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS 0.82 returning ODBC v2 values instead of ODBCv3 values
  • Date: Thu, 17 Dec 2009 11:31:00 -0500

On Thu, Dec 17, 2009 at 04:01:46PM +0100, Michal Seliga wrote:
> hi,
>
> when i am connecting to odbc from qt in linux i had to add connection
> parameter
> SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3, otherwise it also didn't worked properly
>
> i don't know oracle, but try to find if you can set connection parameters
> somewhere, it might help in your case too

The FreeTDS ODBC driver doesn't automatically behave as ODBC v3. It has to
be told to. In C:

SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER));

It seems that other drivers infer the application's intended ODBC version
from the kinds of function calls they make:

http://msdn.microsoft.com/en-us/library/ms714001%28VS.85%29.aspx

"ODBC 3.x applications should never call SQLAllocEnv. As a result, if
the Driver Manager receives a call to SQLAllocEnv, it recognizes the
application as an ODBC 2.x application."

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.odbc/db2z_drivbhav.htm

"The SQL_ATTR_ODBC_VERSION environment attribute controls whether the
DB2? ODBC 3.0driver exhibits ODBC 2.0 or ODBC 3.0 behavior. This value is
implicitly set by the ODBC driver by application calls to the ODBC 3.0
function SQLAllocHandle() or the ODBC 2.0 function SQLAllocEnv()."

Perhaps the Oracle software expects the driver to set the ODBC version
automatically. Adding SQL_ATTR_ODBC_VERSION to the connection string might
help.

--jkl


>
>
> On 17. 12. 2009 15:49, Mike Blake wrote:
> > Just doing isql or tsql I can query the datetime columns. The problem is
> > when I try to query from Oracle. I have a DB link in Oracle pointing to
> > the ODBC connection (FreeTDS). When I try to do the query including the
> > datetime columns in Oracle, the log form Oracle shows the datetime
> > columns being ignored. The datatype code listed for the columns being
> > ignored is 11 (ODBC v2) instead of 93 which is the ODBC v3 code for
> > datetime or timestamp. I need FreeTDS to always use the ODBC v3 values.
> > Is there any way to force it to default to ODBC v3? Or is there
> > something in unixODBC that can be set to force ODBC v3? Anybody who
> > upgrades to Oracle 11 will lose the ability to use FreeTDS if it can't do
> > ODBC v3 by default.
> >
> > I don't get anything very useful in the FreeTDS or unixODBC logs when
> > querying from Oracle since the query fails. I can attach the Oracle log
> > which shows the list of columns being looked at and the datetime columns
> > being ignored due to being datatype 11.




Archive powered by MHonArc 2.6.24.

Top of Page