Hi Monks, I am trying simple stuff. trying to get access to image and store it in a file from Oracle DB of BLOB field. does not matter what format I store an image..as long as I can view it in some ways. I don't know which format images are stored in database. Result..I get some 6029 bytes images with ERROR in that. So, I thought Monks can help me out with my problem. Please see what code I writing.

######### 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 ##############

Thank you so much for your help, Saurin


In reply to displaying BLOB from Oracle : help by sdj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.