pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bill <bouma@cplane.com>
To: pgsql-interfaces@postgresql.org
Subject: SQLColumns not working (ODBC)
Date: Thu, 31 Aug 2000 17:06:56 -0700
Message-ID: <39AEF320.B9B8D2BA@cplane.com> (raw)

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>



Message-ID: <39AEF320.B9B8D2BA@cplane.com>
Permalink:  ../39AEF320.B9B8D2BA@cplane.com/
Also on:    postgresql.org/message-id/39AEF320.B9B8D2BA@cplane.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: bouma@cplane.com
  Subject: Re: SQLColumns not working (ODBC)
  In-Reply-To: <39AEF320.B9B8D2BA@cplane.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox