We've encountered some trouble with fetching CLOBs using a 8.17 client vs.
an Oracle utf8 DB. I'm pretty sure the bug's somewhere in the OCI, but I
may
be wrong, and anyway - maybe you've heard something about this.
When running the following code I get the following output (including
error)
if the client is 8.17 and the DB utf8. If I change to 8.15 or change the
DB
to regular the error isn't raised.
The output:
Starting Length=9
--Step 1 done --
database now open
Table created
Insert Performed
DBD::Oracle::st fetchrow_hashref failed: (DBD NEED_DATA: OCILobRead) at
./testClob.pl line 39.
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
The error, as you can see, is fetched during the "fetchrow_hashref". Any
ideas?
#!/usr/bin/perl -w
use strict;
use DBI;
use DBD::Oracle qw(:ora_types);
my $clob="C" x 9;
print "Starting Length=", length $clob, "\n";
print "--Step 1 done --\n";
my $dbh = DBI->connect("dbi:Oracle(PrintError=>0,AutoCommit=>0):".
"SER_TST","GILAD","GILAD")
|| die "couldn't connect to db";
# drop table but don't die if not there
$dbh->do("drop table foobar");
print "database now open\n";
$dbh->do("CREATE TABLE foobar (foo NUMBER, bar CLOB)");
print "Table created\n";
my $sth = $dbh->prepare("insert into foobar values (?, ?)");
$sth->bind_param(1, "3");
$sth->bind_param(2, $clob, {"ora_type", ORA_CLOB});
$sth->execute()|| die $DBI::errstr;
$sth->finish;
print "Insert Performed\n";
$dbh->{RaiseError} = 1;
$dbh->{LongTruncOk} = 1; # truncation on initial fetch is ok
$sth->{LongReadLen} = 214748647;
$sth = $dbh->prepare("SELECT foo, bar FROM foobar WHERE foo = ?");
$sth->execute(3);
my $row;
print "***";
$row = $sth->fetchrow_hashref;
print"\n";;
$sth->finish;
$dbh->commit();
$dbh->disconnect;
print "Length=",length $row->{BAR}, "\n";
Thanks,
Gilad.