######### my code ######### use strict; use warnings; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBD::Oracle; # Create the CGI object my $cgi = new CGI; ############################################### # Connect to database my $db_server = ""; my $host = $db_server; my $db = ""; my $db_user = ""; my $db_password = ''; my $dbh = DBI->connect("dbi:Oracle:$host", "$db_user", "$db_password") or die "Couldn't connect to database: ".DBI->errstr; my $sql; my $sth; my $table; $table = ""; ##################################################### my $a_pk; my $a_image; my $max_lob; $sql = "select max(length(a_image)) from a_BLOB"; $sth = $dbh->prepare( $sql ); $sth->execute(); $sth->bind_columns(undef,\$max_lob); while($sth->fetch()) { #print "the greatest length image = $max_lob\n"; } $sth->finish(); $dbh->{'LongReadLen'} = $max_lob; ############## $sql = "select a_IMAGE from a_BLOB where a_pk = 123"; $sth = $dbh->prepare( $sql ); my $numrows = $sth->execute; open OUTPUT, ">output.png"; binmode(OUTPUT); $sth->bind_columns(undef,\$sp_image); while($sth->fetch()) { print OUTPUT $sp_image; close(OUTPUT) } $sth->finish; $dbh->disconnect; ########################## code ends ##############