pc88mxer has asked for the wisdom of the Perl Monks concerning the following question:
This will emit:use DBI; my $dbi = DBI->connect(...); sub select_scalar { my ($dbi, $sql) = @_; my $sth = $dbi->prepare($sql); $sth->execute(); my $r = $sth->fetch_row_array(); return $r->[0]; } my $q1 = "select 1 from dual where 'ä' = chr(228)"; my $q2 = $q1.chr(1024); chop($q2); print "q1 eq q2? ", ($q1 eq $q2 ? "yes" : "no"), "\n"; my $r1 = select_scalar($dbi, $q1); print "r1 = $r1\n"; my $r2 = select_scalar($dbi, $q2); print "r2 = $r2\n";
q1 eq q2? yes r1 = 1 r2 =
So, even though q1 and q2 are the same Perl string (character by character), they are different when passed to DBD::Oracle. A fix would be to use Encode::encode('iso-8859-1', ...) on every string passed to DBD::Oracle (query strings as well as values for ? place holders.)
My question: is there another (read 'better') way to do this? I'm using perl 5.8.0 and OCI version 8.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBD::Oracle uses Perl's internal representation of strings
by mje (Curate) on Nov 07, 2007 at 15:02 UTC | |
by pc88mxer (Vicar) on Nov 07, 2007 at 17:19 UTC | |
by mje (Curate) on Nov 07, 2007 at 17:46 UTC |