I am trying to store zip files in Oracle using DBI/DBD::Oracle. System particulars are:
Oracle8i Enterprise Edition Release 8.1.7.0.0
perl, version 5.005_03 built for alpha-dec_osf
$DBI::VERSION = "1.13";
$DBD::Oracle::VERSION = '1.03';

My table has two columns

FILE_NAME VARCHAR2(100)
ZIPFILE   BLOB

The code I have tried is as follows:
#!/usr/bin/perl use strict; use CGI::Carp qw(fatalsToBrowser); use DBI; use DBD::Oracle qw(:ora_types); require "../cbt-lib.pl"; # has header/footer and oracle connect functi +ons &header("blob_test"); my $dbh = &oracleConnectAuth("WRITE"); my $file_name = 'test.zip'; $dbh->{LongReadLen} = 20000 * 1024; &put_blob($dbh,$file_name); &get_blob($dbh,$file_name); $dbh->disconnect; &footer; exit 0; sub put_blob { my ($dbh,$file_name) = @_; my $data; my $blob_data; open (INFILE, "<$file_name") || die "could not $file_name"; binmode INFILE, ":raw"; while(read(INFILE,$data,1024)) { $blob_data .= $data; } close INFILE || die "could not close INfile"; my $sqlstring = "delete from cbt_blob_test"; $dbh->do ($sqlstring) or die "delete:<br>$DBI::errstr<br>$sqlstring"; $sqlstring = "INSERT INTO CBT_BLOB_TEST (FILE_NAME,ZIPFILE) VALUES (?, +?)"; my $sth = $dbh->prepare ($sqlstring) or die "prepare:<br>$DBI::errstr< +br>$sqlstring"; $sth->bind_param(1, $file_name) or die "bind 1 +:<br>$DBI::errstr<br>$sqlstring"; $sth->bind_param(2, $blob_data, {ora_types=>ORA_BLOB} ) or die "bind 2 +:<br>$DBI::errstr<br>$sqlstring"; $sth->execute() or die "execute:\n$DBI::errstr\n$sqlstring"; $sth->finish; $dbh->commit; } sub get_blob { my ($dbh,$file_name) = @_; my $sqlstring = "SELECT ZIPFILE FROM CBT_BLOB_TEST WHERE FILE_NAME = ' +$file_name' "; print "$sqlstring<br>"; my $blobdata = &getDBdata ($sqlstring,$dbh); open (OUTFILE, ">blob_test_output") || die "could not open OUTfile"; binmode (OUTFILE); print OUTFILE $blobdata; close OUTFILE || die "could not close OUTfile"; }
The 'execute' statement in 'get_blob' returns the following error:

ORA-01465: invalid hex number (DBD ERROR: OCIStmtExecute)

I see a lot of questions about blobs and Oracle on the web, but have yet to find much useful code. 

Any assistance would be appreciated.

In reply to Storing/Retrieving Blobs from Oracle by jcbyrne

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.