Hi There,
I would like to insert/update a jpeg file to a table in oracle. The table has three columns,: id (number) , Plot( BLOB), contamination(number).
I need to update the plots column with a JPEG file.
my ($conn);
my($sample_name, $blob_file);
&GetOptions("n=s" =>\$sample_name,
"f=s" =>\$blob_file,
);
my $db_type = 'test'; # or live
my $team = 78;
{
#conn_setup();
update();
}
sub update {
my $conn;
open(BLOB, $blob_file) ||die "Cannot open the blob file\n";
my $bytes = 0;
my $buf;
$bytes = read(BLOB, $buf, 500000);
print STDERR "Read $bytes bytes\n";
close(BLOB);
eval {
$conn = Database::Conn->new('live');#module to connect to DB
$conn->addConnection(DBI->connect('dbi:Oracle:CANT.world', 'nst_own
+er', 'NST_OWNER', {RaiseError => 1, AutoCommit => 0}),'nst');
my $sample_id = $conn->execute('nst::Copynumber::GetCosmicSampleId'
+, $sample_name);
#print $sample_id;
$conn->execute('nst::Copynumber::InsertContourPlots',$buf, $sample_
+id);
};if($@){
warn "ERROR: ".$@;
$conn->rollback;
exit;
} else {
$conn->commit;
}
}
I have tried reading the file in to a string, using 'read' but that got me this error and some pages of non readable errors :(
DBD::Oracle::st execute failed: ORA-01461: can bind a LONG value only for insert into a LONG column
The JPEG files are usually 30KB - 60KB.
Any directions to how to achieve would be very much appreciated.
Thanks in advance.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.