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 e71JwcB92231 for ; Tue, 1 Aug 2000 15:58:38 -0400 (EDT) Received: (qmail 7891 invoked from network); 1 Aug 2000 18:39:39 -0000 Received: from unknown (HELO texas.cplane.com) (unknown) by unknown with SMTP; 1 Aug 2000 18:39:39 -0000 Received: (qmail 19286 invoked from network); 1 Aug 2000 19:58:36 -0000 Received: from unknown (HELO cplane.com) (unknown) by unknown with SMTP; 1 Aug 2000 19:58:36 -0000 Message-ID: <39872BEC.517DD705@cplane.com> Date: Tue, 01 Aug 2000 12:58:36 -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: ODBC interface unable to READ Large Object data Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200008/7 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