There is more than one way of getting this error, but the most common reason is the application calling SQLBindCol with a very large BufferLength
argument. This often arises from the following sequence of events:
SQLPrepare(select bigcol from table) SQLExecute SQLDescribeCol(1) - returns bigcol, which is a big number (e.g. 1073741824) SQLBindCol(1, BufferLength=number_returned_from_SQLDescribeCol)
In effect, the application is saying I have this much memory available for the column data (even if it doesn't). The ODBC-ODBC Bridge Server needs to allocate the same buffer size to hold the data returned from the ODBC driver, and in the case of very large buffers, that is sometimes not possible. In most cases, the application did not intend to do this or does not have that much buffer space available. There is one specific example of this with Perl's DBD::ODBC driver and SQL_WLONGVARCHAR columns:
DBD::ODBC only supports SQL_WLONGVARCHAR if the ODBC header files it is built with include sqlucode.h. In some versions of DBD::ODBC, sqlucode.h is not included, and so when an SQL_WLONGVARCHAR column is seen (ntext in SQL Server) DBD::ODBC ignores LongReadLen
and uses the value from SQLDescribeCol.
When building DBD::ODBC 0.45 or earlier with the ODBC-ODBC Bridge or unixODBC, the Makefile.PL needs to be altered to include sqlucode.h output in dbdodbc.h. To do this:
elsif ($myodbc eq 'esodbc') {
move down the blocks of lines from there until you see print
commands writing #include
lines to SQLH
. At the end of the 3 print commands (but before the end of the block '}') add:
print SQLH qq{#include <sqlucode.h>\n};
-Or
"elsif ($myodbc eq 'unixodbc') {"
Now follow the instructions in the previous bullet.
#include <sqlucode.h>