title: DBI connect failed: ERROR OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID)
body: <p>I'm trying to connect to a remote Oracle database in my perl app. When running the app, the following error appears:</p>
  
  <pre><code>DBI connect('//XXX.XXX.XXX.XXX:1522/TEST','user','password') 
  failed: ERROR OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID)
  Check NLS settings etc. at App.pm line 28.
  </code></pre>
  
  <p>My App.pm</p>
  
  <pre><code>package App;
  
  use strict;
  use warnings;
  
  use DBI;
  
  my $instance = undef;
  BEGIN {
      $ENV{OCI_NLS_CHARSET_ID} = "AMERICAN_AMERICA.CL8MSWIN1251";
      $ENV{ORACLE_HOME} = "path";
  }
  sub get_instance {
      $instance = bless {}, shift unless $instance;
      return $instance;
  }
  
  sub new {
      my ($caller) = @_;
      my $class = ref($caller) || $caller;
      return get_instance($class);
  }
  
  sub connect {
      my $self = shift;
      $self-&gt;{dbh} = DBI-&gt;connect('dbi:Oracle://XXX.XXX.XXX.XXX:1522/TEST', 'user', 'password');
  }
  
  sub DESTROY {
      my $self = shift;
      $self-&gt;{dbh}-&gt;disconnect if $self-&gt;{dbh};
  }
  
  1;
  </code></pre>
  
  <p>NLS_PARAMETERS:</p>
  
  <pre><code>PARAMETER                                                        VALUE
  ---------------------------------------------------------------- ----------------------------------------------------------------
  NLS_LANGUAGE                                                     AMERICAN
  NLS_TERRITORY                                                    AMERICA
  NLS_CURRENCY                                                     $
  NLS_ISO_CURRENCY                                                 AMERICA
  NLS_NUMERIC_CHARACTERS                                           .,
  NLS_CALENDAR                                                     GREGORIAN
  NLS_DATE_FORMAT                                                  DD-MON-RR
  NLS_DATE_LANGUAGE                                                AMERICAN
  NLS_CHARACTERSET                                                 CL8MSWIN1251
  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_NCHAR_CHARACTERSET                                           AL16UTF16
  NLS_COMP                                                         BINARY
  NLS_LENGTH_SEMANTICS                                             BYTE
  NLS_NCHAR_CONV_EXCP                                              FALSE
  
  19 rows selected
  </code></pre>
  
  <p>I'm using ActiveStat perl on Windows 7. 
  Server ORACLE 11.2.0.2.0 x64 on Windows 2003. 
  DBI 1.634. 
  DBI-Oracle 1.74.</p>
  
  <p>On server, application is running successfully.</p>