help! ora_lob_append / ora_lob_write fails when writing to a blob column in Oracle
- From: ccaneda@xxxxxxxxx
- Date: 11 Jul 2006 05:15:31 -0700
Hi,
I'm trying to insert a file to a blob column. I can get upto retrieving
the blob locator but when i'm writing the contents of the file via
ora_lob_write or ora_lob_append, the procedure fails and I get the
error - "Error on ora_lob_append writing to filestorage table in
database" which I specified.
I've written the following code which I picked up from online
documents. I'm using Oracle8i EE.
Please help.
use DBD::Oracle qw( :ora_types);
my $dbh = DBI->connect( 'dbi:Oracle:host', 'test, 'testpass', {
RaiseError => 1, AutoCommit => 0 } ) || die DBI->errstr;
my $sth = $dbh->prepare("SELECT FileID.NEXTVAL FROM Dual");
$sth->execute;
my $fileid = $sth->fetchrow_array;
$sth = $dbh->prepare("INSERT INTO filestoragetest (FILEID, DATA)
VALUES (?, ?)");
$sth->bind_param(1,$fileid);
$sth->bind_param(2,'',{ ora_type => ORA_BLOB});
$sth->execute();
$sth = $dbh->prepare( <<" SQL", { ora_auto_lob => 0 } );
SELECT data FROM filestoragetest WHERE fileid = ? FOR UPDATE
SQL
$sth->execute( $fileid );
my $bin_locator = $sth->fetchrow_array();
$sth->finish;
open BINFILE, "testupload.txt" or die $!;
my $buffer ='';
my $chunk_size = 4096;
eval {
while( read( BINFILE, $buffer, $chunk_size ) ) {
$dbh->ora_lob_append( $bin_locator, $buffer );
}
};
if ($@) {
$dbh->rollback;
$error .= "Error on ora_lob_append writing to filestorage
table in database. \n";
$error .= $dbh->errstr;
} else {
$dbh->commit;
}
close(BINFILE);
$sth->finish;
.
- References:
- Displaying Oracle BLOB with perl
- From: Roberto Quijalvo
- Displaying Oracle BLOB with perl
- Prev by Date: AW: mysql installation problems
- Next by Date: RE: mysql installation problems
- Previous by thread: Displaying Oracle BLOB with perl
- Next by thread: Re: Displaying Oracle BLOB with perl
- Index(es):
Relevant Pages
|
|