Re: DBD::Oracle and Perl's internal representation of strings



On Nov 9, 2007 4:47 AM, Charles Jardine <cj10@xxxxxxxxx> wrote:
On 07/11/07 17:38, E R wrote:
Hi,

I just posted this question on Perl Monks:

http://perlmonks.com/?node_id=649489

Am I correct in my analysis of what's going?

You might be interested in a thread which I started just over
two years ago. See

http://www.nntp.perl.org/group/perl.dbi.users/2005/08/msg27335.html

This is exactly the issue I am trying to raise. The only solution
seems to be to explicitly
encode all the strings in the encoding you want before passing them to
DBD::Oracle.
For example, instead of:

$sth = $dbi->prepare($sql);
$sth->execute(@values);

one would have to write something like:

$sth = $dbi->prepare(Encode::encode('iso-8859-1', $sql));
$sth->execute(map { Encode::encode('iso-8859-1', $_) } @values);

(Of course, there are more efficient ways to do this.)

Consequently, for those of us who are using only iso-8859-1 in our SQL
and in our database, it would be very useful to have an interface to
DBD::Oracle which performed this encoding automatically. An exception
could be thrown if a string containing a character > 255 were passed.
I could write such an interface in Perl, but I was wondering if the
same thing could be effected within DBD::Oracle through some
configuration settings.

As you will see, the thread never reached a satisfactory conclusion.

I haven't read through the entire thread, but it seems that
DBD::Oracle has to be treated as what I call an "octet sequence
interface". That is, the caller is responsible for properly encoding
and decoding the results. At least this is what I have to do. Someday
it would be nice to have a true "text" interface that would
automatically negotiate all the character encoding issues along the
pipeline from Perl to the database.

Sadly, I have not been able to find the time to work on anything
DBI related since that posting.

Thanks for bringing this thread up - it's been very helpful!
.



Relevant Pages

  • python-2.3.3 build failing
    ... XFree86-libraries-4.3.0_6 XFree86-4 libraries and headers ... infobot-0.44.5 Bot written in Perl with a rabid AI ... libident-0.22 A small library to interface the ident protocol server (rfc ... p5-Authen-SASL-2.04 Perl5 module for SASL authentication ...
    (freebsd-questions)
  • Re: X-4.3.0_6 not building from /usr/ports
    ... bsdpan-Event-0.87 Unknown perl module ... cyrus-sasl-saslauthd-2.1.15_3 SASL authentication server for cyrus-sasl2 ... p5-CGI.pm-2.97,1 Simple Common Gateway Interface Class for Perl ... p5-Config-IniFiles-2.27 Perl5 module for reading .ini-style configuration files ...
    (freebsd-questions)
  • Re: UTF8: cgi ist staerker als ich
    ... use locale ist sogar äusserst gefährlich und unberechenbar. ... Also vergiss Locales und verwende den Unicode-Support von Perl. ... ist dass Du nicht 256 verschiedene Zeichen ... Beim encode kodierst Du Zeichen entsprechend einem bestimmten Encoding ...
    (de.comp.lang.perl.cgi)
  • Re: UTF8: cgi ist staerker als ich
    ... "Perl und seine Module" ist Unsinn. ... Dass ich "encoding" insgesamt nicht verwenden duerfe, ... Wenn man Fehler gar nicht erst macht, ...
    (de.comp.lang.perl.cgi)
  • Re: UTF8: cgi ist staerker als ich
    ... dass eine alte Version von Perl eine neue Version ... funktionieren) hat er es vielleicht noch nicht bemerkt. ... entsinne, habe ich zwei Versuche gebraucht, weil ich Dein "use encoding" ... Um bei dem hinkenden Vergleich zu bleiben: Wenn auf der Packung steht, ...
    (de.comp.lang.perl.cgi)