Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle's RPAD problematic via Perl's DBI module
In comp.lang.perl.misc dn_perl_at_hotmail.com <dn_perl_at_hotmail.com> wrote:
: Say the table is : students(name CHAR(8))
: Entries in Students are : ' ' (8 blanks),
: 'bob ' and 'dave ' .
: my $st_name = " " ; # non-blank name
: my $dstmt = $dbh->prepare("select count(*) from students
: where name = RPAD(?,8) ") ; # STMT AA
: $dstmt->execute($st_name) or die "sql call failed";
: my $num_entries = $dstmt->fetchrow() ;
: $dstmt->finish ;
: $num_entries should be set to 1; instead it is set to 0.
: This problem occurs only for a blank string.
: But still I am surprised why STMT AA (above) fails to return
: the expected result.
What Oracle Version are you using? There are some subtle differences in the handling of trailing blanks between Oracle 8 and 9. I have a table "foo" containing two blank entries. When running the following code
my $ss = "SELECT COUNT(*) FROM foo WHERE bar = RPAD(?,8)"; my $blank = ' '; my $sth = $dbh->prepare($ss) or die;
I get the following result:
Blank: 2 # Oracle 9 database using local Oracle 9 client Blank: 2 # Oracle 9 client connecting to a remote Oracle 8 database Blank: 0 # Oracle 8 database using local Oracle 8 client Blank: 0 # Oracle 8 client connecting to a remote Oracle 9 database
Peter
-- Peter Marksteiner Vienna University Computer CenterReceived on Wed Aug 25 2004 - 04:44:24 CDT
![]() |
![]() |