SQLColumns not working (ODBC) - Mailing list pgsql-interfaces

From Bill
Subject SQLColumns not working (ODBC)
Date
Msg-id 39AEF320.B9B8D2BA@cplane.com
Whole thread Raw
List pgsql-interfaces
This is postgresql 7.x and unixODBC-1.8. It worked under 6.5. 

Here is a simple function to print the column names in a table:
-------------------------------------------------------------------
void printColumnNames(SQLHANDLE hdbc, char *tableName) {   SQLCHAR colName[80];   SQLHANDLE stmt;
   fprintf(stderr, "Table %s has columns:\n", tableName);   SQLRETURN retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc,
&stmt);  if (SQL_SUCCEEDED(retcode)) {       retcode = SQLColumns(stmt, NULL, 0, NULL, 0,                   (SQLCHAR
*)tableName,SQL_NTS, NULL, 0);       if (SQL_SUCCEEDED(retcode)) {           retcode = SQLBindCol(stmt, 4, SQL_C_CHAR,
(SQLPOINTER)&colName,                      sizeof colName, NULL);           while (retcode != SQL_NO_DATA) {
  retcode = SQLFetch(stmt);               if (SQL_SUCCEEDED(retcode))                   fprintf(stderr, "%s\n",
colName);          }       }   }   //dumpODBCLog(stmt);   SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 
}
--------------------------------------------------------------------
Not only does this function not print the column names, but after
it is called, SQLFetch() no longer works at all.  If you watch it
in the debugger, all the calls succeed, except the fetch.  The log
says (exactly):
Couldnt open large object for reading.;
ERROR:  Relation 23 does not exist

Bill <bouma@cplane.com>


pgsql-interfaces by date:

Previous
From: Tom Lane
Date:
Subject: Re: ODBC: Declare/Fetch & SELECT INTO
Next
From: Dave Page
Date:
Subject: RE: ODBC: Declare/Fetch & SELECT INTO