DBD::Oracle and utf8

Posted by golemwashere on Stack Overflow See other posts from Stack Overflow or by golemwashere
Published on 2010-04-09T14:51:48Z Indexed on 2010/04/09 19:03 UTC
Read the original article Hit count: 607

Filed under:
|
|
|

Hello, I have some troubles inserting an UTF8 string into an oracle 10 database on Solaris, using the latest DBD::Oracle on perl v5.8.4.

This are my DB settings

> --------SELECT * from NLS_DATABASE_PARAMETERS-------------------------------
> NLS_NCHAR_CHARACTERSET AL16UTF16
> NLS_LANGUAGE AMERICAN
> NLS_TERRITORY AMERICA NLS_CURRENCY $
> NLS_ISO_CURRENCY AMERICA
> NLS_NUMERIC_CHARACTERS .,
> NLS_CHARACTERSET UTF8
> NLS_CALENDAR GREGORIAN
> NLS_DATE_FORMAT DD-MON-RR
> NLS_DATE_LANGUAGE AMERICAN
> NLS_SORT BINARY
> NLS_TIME_FORMAT HH.MI.SSXFF AM
> NLS_TIMESTAMP_FORMAT DD-MON-RR
> HH.MI.SSXFF AM
> NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
> NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR
> HH.MI.SSXFF AM TZR NLS_DUAL_CURRENCY $
> NLS_COMP BINARY
> NLS_LENGTH_SEMANTICS CHAR
> NLS_NCHAR_CONV_EXCP FALSE
> NLS_RDBMS_VERSION 10.2.0.4.0
> --------------------------------------------------------------------------

This are my perl $dbh->ora_nls_parameters()

$VAR1 = {
          'NLS_LANGUAGE' => 'AMERICAN',
          'NLS_TIME_TZ_FORMAT' => 'HH.MI.SSXFF AM TZR',
          'NLS_SORT' => 'BINARY',
          'NLS_NUMERIC_CHARACTERS' => '.,',
          'NLS_TIME_FORMAT' => 'HH.MI.SSXFF AM',
          'NLS_ISO_CURRENCY' => 'AMERICA',
          'NLS_COMP' => 'BINARY',
          'NLS_CALENDAR' => 'GREGORIAN',
          'NLS_DATE_FORMAT' => 'DD-MON-RR',
          'NLS_DATE_LANGUAGE' => 'AMERICAN',
          'NLS_TIMESTAMP_FORMAT' => 'DD-MON-RR HH.MI.SSXFF AM',
          'NLS_TERRITORY' => 'AMERICA',
          'NLS_LENGTH_SEMANTICS' => 'CHAR',
          'NLS_NCHAR_CHARACTERSET' => 'AL16UTF16',
          'NLS_DUAL_CURRENCY' => '$',
          'NLS_TIMESTAMP_TZ_FORMAT' => 'DD-MON-RR HH.MI.SSXFF AM TZR',
          'NLS_NCHAR_CONV_EXCP' => 'FALSE',
          'NLS_CHARACTERSET' => 'UTF8',
          'NLS_CURRENCY' => '$'
        };

In my script I have:

use utf-8;
$ENV{NLS_LANG}='AMERICAN_AMERICA.UTF8';
..
$sth->bind_param(5, $myclobfield, {ora_type => ORA_CLOB, ora_csform => SQLCS_NCHAR});
..

The string prints out 1 on

print Encode::is_utf8($myclobfield);

But characters like òàè are not correctly inserted into the DB. (I tested with a utf8 compliant client that can correctly insert and read them)

Can anyone suggest the best way to do it? Thanks

© Stack Overflow or respective owner

Related posts about perl

Related posts about Oracle