I'm writing a CGI script in Perl to extract longs from an Oracle
database that contain jpeg images and package them for display in a
web page. I've got a script to put them into the database, which I
thought would be the hard part. But I'm struggling with this.

I'm using Perl 5.004_01, DBI version .90, DBD::Oracle version .47
and Oracle version 7.3.2.1. The image I'm extracting for this test
is about 232Kb. The weird part is that when I set different values
for LongReadLen I get odd data lengths back, none of which are
close to what I specify. As examples:

$dbh->{LongReadLen} = 500120;      gives me 41369 characters
$dbh->{LongReadLen} = 500 * 1024;  gives me 53249 characters
$dbh->{LongReadLen} = 800 * 1024;  gives me 32769 characters
$dbh->{LongReadLen} = 300 * 1024;  gives me 45057 characters

These results come from running the script by hand from the command
line. My suspicion is that this is caused by my use of an old version
of something, but that's just a guess from what I've been reading here
and elsewhere on the net. If anyone has other suggestions of other
possible causes, I would appreciate any assistance or suggestions.

Thanks.

Dan Olson
Senior Research Associate
Oregon Health & Science University


The code:

#! /usr/local/bin/perl

use DBI;
use CGI;

$query = new CGI;

if ($picID = $query->param('ID')) {
        $dbh = DBI->connect('dbi:Oracle:meta','chinese','china') or die
"Can't open database connection: $DBI::errstr\n";

        $dbh->{LongReadLen} = 300 * 1024;
        $dbh->{LongTruncOk} = 1;

        $dbq = $dbh->prepare("select image from wcare_test where pid =
$picID");
        $dbq->execute;

        ($image) = $dbq->fetchrow() or die "Can't execute fetchrow:
$DBI::errstr\n";
        print "picID is $picID; pid is $pid; size of image: " .
length($image) . " characters\n";
        $dbq->finish;
        $dbh->disconnect;

}

Reply via email to