Received: from cplane.com (IDENT:qmailr@jersey.cplane.com [63.193.105.226]) by hub.org (8.10.1/8.10.1) with SMTP id e8107JC10128 for ; Thu, 31 Aug 2000 20:07:19 -0400 (EDT) Received: (qmail 20547 invoked from network); 31 Aug 2000 22:46:32 -0000 Received: from unknown (HELO texas.cplane.com) (unknown) by unknown with SMTP; 31 Aug 2000 22:46:32 -0000 Received: (qmail 22872 invoked from network); 1 Sep 2000 00:06:56 -0000 Received: from unknown (HELO cplane.com) (unknown) by unknown with SMTP; 1 Sep 2000 00:06:56 -0000 Message-ID: <39AEF320.B9B8D2BA@cplane.com> Date: Thu, 31 Aug 2000 17:06:56 -0700 From: Bill X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: SQLColumns not working (ODBC) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200008/197 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