DBD::Oracle trims the trailing spaces by default.
try this select * from bar where bar = rpad(?, 8).

or 

use DBI;
use DBD::Oracle qw(:ora_types);

my $dbh = DBI->connect( "dbi:Oracle:", "user/passwd", "",
                         {RaiseError => 1} ) or die $DBI::errstr;

$dbh->{ora_ph_type} = 96;

  
On 12-Jun-01 Rick Osterberg wrote:
> Nope -- doesn't work either.  (I had neglected to mention... we had tried
> that, too.)
> 
> -Rick
> 
> On Tue, 12 Jun 2001, Wilson, Doug wrote:
> 
>> Maybe it is binding as a number. Try:
>> $sth->bind_param(1, $value, { TYPE => SQL_CHAR });
>> before the execute instead of putting $value in the execute;
>>
>> -----Original Message-----
>> From: Rick Osterberg [mailto:[EMAIL PROTECTED]]
>> Sent: Tuesday, June 12, 2001 2:04 PM
>> To: '[EMAIL PROTECTED]'
>> Subject: Strange CHAR/Oracle/DBI issue
>>
>>
>> Strange one here to pass by everyone:
>>
>> Oracle 8.0.5.1.1 server
>> Perl 5.00503 (on both alpha-dec_osf and Solaris)
>> DBI 1.14
>>
>> Take an Oracle table FOO, with a single field BAR which is a CHAR(8).
>> Most everything in that field BAR is 8-characters long, but there are a
>> couple that are 5 characters long.
>>
>> In SQLPLUS, I can do:
>>
>> SQL> SELECT COUNT(*) FROM FOO WHERE BAR = '12345';
>> or
>> SQL> SELECT COUNT(*) FROM FOO WHERE BAR = '12345   ';
>>
>> Both work, and give the correct value.
>>
>> However, from Perl/DBI:
>>
>> $sql = "SELECT COUNT(*) FROM FOO WHERE BAR = ?";
>> $sth = $dbh->prepare($sql);
>> $value = '12345';
>> $sth->execute($value);
>> ($result) = $sth->fetchrow_array();
>>
>> The $result is always zero, which is incorrect.  Stays like that even if I
>> change
>>
>> $value = '12345';
>> to
>> $value = '12345   ';
>>
>> What am I missing?
>>
>> -Rick
>>
>> +--------------------------------------------------------------------------+
>> |                 Rick Osterberg   [EMAIL PROTECTED]                |
>> |         Database Applications Specialist     FAS Computer Services       |
>> +--------------------------------------------------------------------------+
>>
> 
> +--------------------------------------------------------------------------+
>|                 Rick Osterberg   [EMAIL PROTECTED]                |
>|         Database Applications Specialist     FAS Computer Services       |
> +--------------------------------------------------------------------------+
> 

----------------------------------
E-Mail: Scott T. Hildreth <[EMAIL PROTECTED]>
Date: 12-Jun-01
Time: 16:43:41
----------------------------------

Reply via email to