From: | Bill <bouma(at)cplane(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | SQLColumns not working (ODBC) |
Date: | 2000-09-01 00:06:56 |
Message-ID: | 39AEF320.B9B8D2BA@cplane.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)cplane(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Page | 2000-09-01 08:24:27 | RE: ODBC: Declare/Fetch & SELECT INTO |
Previous Message | Dave Page | 2000-08-31 22:07:28 | ODBC: Declare/Fetch & SELECT INTO |