Thread: PostgeSQL & odbctest & SQL_NO_DATA_FOUND

PostgeSQL & odbctest & SQL_NO_DATA_FOUND

From
Graydon
Date:

Hello,

I have spent several hours of tracking down a setup issue with PostgreSQL & iODBC 3.0.5.  While I now have it working, I am still confused as to why it works the way it does and am hoping someone out there has the answer.

I set up odbcinst.ini and assigned it to the environmental variable ODBCINSTINI.
I set up odbc.ini and assigned it to the environmental variable ODBCINI.

When I used odbctest to access PostgreSQL using the connect string dsn=PostgreSQL, I kept getting:

SQLAllocEnv ( ... )
SQL_SUCCESS

SQLAllocConnect ( ... )
SQL_SUCCESS

SQLDriverConnect ( ... )
SQL_NO_DATA_FOUND

SQLError ( ... )
SQL_NO_DATA_FOUND

SQLError ( ... )
SQL_NO_DATA_FOUND

SQLFreeConnect ( ... )
SQL_SUCCESS

When I used a connect string which specified the dsn, server, port and database it worked correctly.

In tracing the problem down, it appears that the odbctest program looks at the odbc.ini file specified in ODBCINI only until SQLAllocConnect is complete.  From that point on, it ignores what is in ODBCINI and only attempts to access the odbc.ini file in {$HOME}/.odbc.ini.

Therefore, copying the odbc.ini to {$HOME}/.odbc.ini allows a connect to be made using just the dsn.

Does anyone know why it works this way?  Is this a problem with PostgreSQL, iODBC or odbctest?  I would very much like to use ODBCINI to specify which odbc.ini to use rather than have copies in everyone's {$HOME}.

Thanks in advance,

Graydon Gorby
Positive Business Solutions, Inc.