Обсуждение: SQLColumns not working (ODBC)

Поиск
Список
Период
Сортировка

SQLColumns not working (ODBC)

От
Bill
Дата:
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>