From: Bill <bouma@cplane.com>
To: pgsql-interfaces@postgresql.org
Subject: ODBC interface unable to READ Large Object data
Date: Tue, 01 Aug 2000 12:58:36 -0700
Message-ID: <39872BEC.517DD705@cplane.com> (raw)
When you write a binary buffer to postgresql through ODBC, it seems
you can control whether or not it writes out as a Large Object or not.
If you use the type SQL_VARBINARY it writes the bytes directly into
the column, if SQL_LONGVARBINARY it just writes the OID into
the column. This is good (enough).
The problem is that when you try to read the data in the case of an OID,
it reads just the OID, and not the data. There seems to be a missing level
of indirection. The JDBC driver handles this by checking if the column
holds an OID or not, then doing the right thing based on that. It would
be nice if ODBC did something similar. Or, perhaps there is some special
way of getting LOB data out of postgresql through ODBC?
This is the code I use to write:
char *insertStmtString = "insert into test_table (id, test_col) values (?,
?)";
SQLINTEGER modifier = SQL_DATA_AT_EXEC;
SQLBindParameter(insertStmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
SQL_LONGVARBINARY, buflen, 0, 0, 0, &modifier);
SQLPutData(insertStmt, buf, buflen);
This is the code for read:
char *readStmtString = "select test_col from test_table where id = ?";
SQLFetch(readStmt);
SQLGetData(readStmt, 1, SQL_C_BINARY, (SQLPOINTER)buf, buflen,
(SQLINTEGER *)datalen);
After calling that, buf = "19553", for example.
Bill <bouma@cplane.com>
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: ODBC interface unable to READ Large Object data
In-Reply-To: <39872BEC.517DD705@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