ODBC interface unable to READ Large Object data

Поиск
Список
Период
Сортировка
От Bill
Тема ODBC interface unable to READ Large Object data
Дата
Msg-id 39872BEC.517DD705@cplane.com
обсуждение исходный текст
Список pgsql-interfaces
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>





В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Bill
Дата:
Сообщение: JDBC driver writes binary data ONLY as Large Object
Следующее
От: Mark Radulovich
Дата:
Сообщение: ODBC Benchmark