-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I like to think that the below script is self-explanatory. Tested on Slackware
Linux 7.0, kernel 2.4.0, with Oracle 8.1.6.
#!/usr/bin/perl -w
use strict;
use vars qw($db);
use DBI;
use DBD::Oracle qw(:ora_types);
DBCONNECT: {
$ENV{'ORACLE_HOME'} = '/opt/oracle/app/oracle/product/8.1.6';
my $user = 'iqgroup';
my $password = 'einstein';
my $sid = 'iqc.devel.theiqgroup.com';
my $opts = {
RaiseError => 1,
PrintError => 0,
AutoCommit => 0,
ChopBlanks => 1,
LongReadLen => 1000000
};
$db = DBI->connect("DBI:Oracle:$sid", $user, $password, $opts)
or die "Can't connect to Oracle: $DBI::errstr";
}
my $lobvalue = 'a' x 4010;
{
local $db->{RaiseError} = 0;
$db->do('CREATE TABLE foo (col1 CHAR(1), col2 CHAR(2), col3 CLOB)');
$db->do('CREATE TABLE bar (col1 CHAR(1), col2 CHAR(2), col3 CLOB)');
}
my $st = $db->prepare('INSERT INTO foo (col1, col2, col3) VALUES (?,?,?)');
# These three very basic ones work fine
$st->execute('A','A','A');
$st->execute('B','B','');
$st->execute('C','C',undef);
# And so does this
$st->bind_param(1,'D');
$st->bind_param(2,'D');
$st->bind_param(3,$lobvalue,{ ora_type => ORA_CLOB });
$st->execute;
# Uncomment this, though, and behold an ORA-22923: amount of data specified in
# streaming LOB write is 0 (even though the LOB value is length 1)
#$st->bind_param(1,'E');
#$st->bind_param(2,'E');
#$st->bind_param(3,' ',{ ora_type => ORA_CLOB });
#$st->execute;
# Uncomment this and you get an ORA-03124: two-task internal error
#$st->bind_param(3,'',{ ora_type => ORA_CLOB });
#$st->execute('F','F','');
# This will also generate an ORA-03124
#$st->bind_param(3,undef,{ ora_type => ORA_CLOB });
#$st->execute('G','G',undef);
# Add a second statement handle and it gets even weirder
my $st2 = $db->prepare('INSERT INTO bar (col1, col2, col3) VALUES (?,?,?)');
# This normally works okay, but leave it commented for a sec...
#$st2->bind_param(3,$lobvalue,{ ora_type => ORA_CLOB });
#$st2->execute('H','H',$lobvalue);
# This causes a segmentation fault, *unless* you uncomment the above --
# then both work okay (?!?!?!?)
$st2->bind_param(3,undef,{ ora_type => ORA_CLOB });
$st2->execute('J','J',undef);
__END__
Please share your own results with this.
- --
Stephen Clouse <[EMAIL PROTECTED]>
Senior Programmer, IQ Coordinator Project Lead
The IQ Group, Inc. <http://www.theiqgroup.com/>
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
iQA/AwUBOncQIAOGqGs0PadnEQJBXgCg8Vl5Br4b5l1rPPsnGGCB5de3dfQAoLQd
HUkU3UyF8whLahZNxlAkWfdY
=jSKF
-----END PGP SIGNATURE-----