Hi Perl Gurus,

        I have a perl script that accesses a BLOB of data from the DB. The 
data is zipped data and I need to be able to get the blob data, unzip it and 
then read the data (the data i zipped XML).

    I have written a small snippet to actually just try to access the BLOB 
from the DB and it doe snot seem to work. Any help is highly appreciated. 
Here is the code:

#!/usr/bin/perl -w

use DBI;
use Data::Dumper;
use strict;
use File::Path ();
use Getopt::Long;
use DBIx::BLOB::Handle;
use DBIx::Table2Hash;

my $chunk;
my 
$dbh=DBI->connect("dbi:Oracle:(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=devdb.vip.com)(PORT=1529))(CONNECT_DATA=(SID=blah)))",
 
"abc", "abcd", {AutoCommit=>1, PrintError=>1, RaiseError=>1});
$dbh->{LongTruncOk} = 1;
$dbh->{LongReadLen} = 10000;
my $insert_into = $dbh->prepare_cached(q{
 select publish_data
 from DT_PUBLISH_DATA where publish_id=12
}) || die "Cannot fetch machines with attributes caches\n";
#print "Coming here\n";
my $sql = "select publish_data from DT_PUBLISH_DATA where publish_id=12";
my $sth = $dbh->prepare($sql);
$sth->execute;
$sth->fetch;
my $fh = DBIx::BLOB::Handle->new($sth,0,4096);
print while <$fh>;
print STDERR 'Size of LOB was ' . $fh->tell . " bytes\n";
print $chunk while read($fh,$chunk,undef);
local $/;
#my $blob = <$handle>;
$insert_into->finish;
$dbh->disconnect;

Below is the error I keep getting:
$ perl Test_Blob.pl
DBD::Oracle::st execute failed: ORA-00932: inconsistent datatypes (DBD: 
oexfet error, e.g., can't select LOB fields using DBD::Oracle built for 
Oracle 7) at Test_Blob.pl line 25.
DBD::Oracle::st execute failed: ORA-00932: inconsistent datatypes (DBD: 
oexfet error, e.g., can't select LOB fields using DBD::Oracle built for 
Oracle 7) at Test_Blob.pl line 25.

Thanks
NRK 


Reply via email to