htrobert has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I got a program to insert and retrieve an image from DB2, but the images I'm getting back are truncated. Either the insert is not inserting all the data, or the retrieve is failing to retrieve it all. My files are all under 15KB. What should I do to expand the buffer? I'm connecting via DBI:DB2. My code already has
$dbh ->{LongReadLen} = 512 * 1024 ; $dbh ->{LongTruncOk} = 0 ;

Replies are listed 'Best First'.
Re: DBI::DB2 buffer problem
by ghettofinger (Monk) on Jan 14, 2005 at 20:30 UTC
    What is your datatype for the column that holds the image? It may not be large enough. Have you checked your db logs?

    ghettofinger

Re: DBI::DB2 buffer problem
by dazzle (Sexton) on Jan 18, 2005 at 21:02 UTC

    First question: when you're writing out the images to the file handle, are you setting binmode on the file handle? Some operating systems have a lovely habit of truncating files on the first CTRL-Z character they see -- not that you've told us what operating system you're running your program on.

    That looks like code directly from the Perl sample 'dtlob.pl' included with DB2 for Linux, UNIX, and Windows in the ~/sqllib/samples/perl/ directory (visible online in the DB2 Information Center)

    Have you tried running that sample program against the DB2 SAMPLE database (created with the db2sampl command)? If the sample program works, then the problem is either with your application, your database schema, or your builds of DBI (current version 1.46) or DBD::DB2 (current version 0.78).

    Are you connecting to a DB2 for Linux, UNIX, and Windows database server, or to a DB2 for iSeries or zSeries server?

    To really assist you, you need to give us more information.

    Note that the DBD::DB2 driver is officially supported by IBM, so you can open a PMR (problem report) if you have a support contract for DB2 with IBM. Of course, you'll need to provide much more information than you've provided here.