in reply to dbix::simple & varbinary(MAX)

I just encountered this same problem. It appears to be an issue with DBD::ODBC itself. You can patch dbdimp.c and rebuild your Perl module and that should fix it. Here's a diff against DBD::ODBC 1.16:
(root@ravyn 16:40:05)# diff dbdimp.c ~root/dbdimp.new.c 1897d1896 < case SQL_VARBINARY: 1933a1933,1940 > case SQL_VARBINARY: > fbh->ftype = SQL_C_BINARY; > case SQL_VARCHAR: > case SQL_WVARCHAR: > if (fbh->ColDef == 0) { > fbh->ColDisplaySize = DBIc_LongReadLen(imp_sth); > } > break;
Credit goes to Fumiaki Yoshimatsu for solving the problem a couple years ago (I found the solution on Google) - not sure why it's not in the mainline DBD::ODBC code, but it works well enough for my applications, so I'm not complaining.

Replies are listed 'Best First'.
Re^2: dbix::simple & varbinary(MAX)
by mje (Curate) on Aug 01, 2008 at 14:33 UTC

    I don't know where you got that 1.16 distribution from because the diff does not make sense against 1.16 code at that point which already contains:

    case SQL_VARBINARY: case SQL_BINARY: fbh->ftype = SQL_C_BINARY; break; #if defined(WITH_UNICODE) case SQL_WCHAR: case SQL_WVARCHAR: fbh->ftype = SQL_C_WCHAR; /* MS SQL returns bytes, Oracle returns characters ... */ fbh->ColDisplaySize*=sizeof(WCHAR); fbh->ColLength*=sizeof(WCHAR); break; #endif /* WITH_UNICODE */

    However, the salient point of it is setting ColDisplaySize.

    The reason why it is not in DBD::ODBC is no one has told the current maintainer about it - namely me - I just came across this thread. This will be included in 1.17.

      > This will be included in 1.17. I am soooo glad to read this! I am sorry I was a newbie at that time and just posted my patch to DBI-users email list so that slipped from your radar. http://www.mail-archive.com/dbi-users@perl.org/msg26962.html Anyway, I can't wait to see this included! Thanks!
        I was not the maintainer back then. Anyway, a developer release 1.16_4 has been uploaded to CPAN (and should appear soon) which fixes the issue you reported here (namely varXXX(max types)). In the mean time you can get it from ftp://ftp.easysoft.com/pub/DBD-ODBC-1.16_4.tar.gz