Hi Tim.
I've found a bug in DBD::Oracle which is related to LOBs and case sensitive
field names. I have to use 1.06 version but the bug still presents in 1.12.

Example:
table:
create table test("Field1" clob,"Field2" clob);

test script1:

use strict;
use DBI;
use DBD::Oracle qw(:ora_types);
my $dbh = DBI->connect("dbi:Oracle:","root","qwerty") or die $DBI::errstr;
my $sth = $dbh->prepare('insert into test("Field1", "Field2")
 values(?,?)') or die $dbh->errstr;
$sth->bind_param(1,'',{ ora_type=>ORA_CLOB, ora_field=>'"Field1"' }) or
 die $sth->errstr;
$sth->bind_param(2,'',{ ora_type=>ORA_CLOB, ora_field=>'"Field2"' }) or
 die $sth->errstr;

$sth->execute or die $sth->errstr;

The script above fails with a message "DBD::Oracle::st execute failed:  (DBD ERROR: 
Can't match some parameters to LOB fields in the table, check type and name) at q.pl 
line 13."

Test script 2 in which ora_field=>'"Field*"' is replaced by ora_field=>'Field*'

use strict;
use DBI;
use DBD::Oracle qw(:ora_types);
my $dbh = DBI->connect("dbi:Oracle:","root","qwerty") or die $DBI::errstr;
my $sth = $dbh->prepare('insert into test("Field1", "Field2")
 values(?,?)') or die $dbh->errstr;
$sth->bind_param(1,'',{ ora_type=>ORA_CLOB, ora_field=>'Field1' }) or
 die $sth->errstr;
$sth->bind_param(2,'',{ ora_type=>ORA_CLOB, ora_field=>'Field2' }) or
 die $sth->errstr;
$sth->execute or die $sth->errstr;

fails with DBD::Oracle::st execute failed: ORA-00904: invalid column name (DBD ERROR: 
OCIStmtExecute/LOB refetch) at q.pl line 13.


I've made a quick hack which fixes it:

C:\SW_ENV\sw_env_1.3\DBD-Oracle-1.06>diff oci8.c.orig oci8.c
1253,1254c1253,1262
<               if (SvCUR(phs->ora_field) != SvCUR(sv)
<               || ibcmp( SvPV(phs->ora_field,na), SvPV(sv,na), SvCUR(sv) ) )
---
>               char bfield[256];
>               strcpy(bfield,SvPV(phs->ora_field,na));
>               if (bfield[0] == '\"' && bfield[strlen(bfield) - 1] == '\"') {
>                   strcpy(bfield, bfield + 1);
>                   bfield[strlen(bfield) - 1] = 0;
>               }
> /*            if (SvCUR(phs->ora_field) != SvCUR(sv)
>               || ibcmp( SvPV(phs->ora_field,na), SvPV(sv,na), SvCUR(sv) ) )*/
>               if (strlen(bfield) != SvCUR(sv)
>               || ibcmp( bfield, SvPV(sv,na), SvCUR(sv) ) )
1277c1285,1287
<           sprintf(sql_field, "%s%s \"%s\"",
---
>
>
>           sprintf(sql_field, "%s\"%s\" \"%s\"",


Regards, Oleg




 

Reply via email to