Why does Perl DBI complain about "failed: ERROR OCIEnvNlsCreate" when I try to connect to Oracle 11g?

I get the following error: connecting to an Oracle 11g database using a simple Perl script:

 failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var  or PATH (Windows) and or NLS settings, permissions, etc. at

The script looks like this:

#!/usr/local/bin/perl

use strict;
use DBI;

if ($#ARGV < 3) {
print "Usage: perl testDbAccess.pl dataBaseUser dataBasePassword SID dataBasePort\n";
exit 0;
}
my ($user, $pwd, $sid, $port) = @ARGV;

my $host = `hostname`;
my $dbh;
my $sth;
my $dbname = "dbi:Oracle:HOST=$host;SID=$sid;PORT=$port";

openDbConnection();
closeDbConnection();

sub openDbConnection() {
        $dbh = DBI->connect ($dbname, $user ,$pwd , { RaiseError => 1}) || die "Database connection not made: $DBI::errstr";
}

sub closeDbConnection() {
        #$sth->finish();
        $dbh->disconnect();
}

Has anyone seen this problem before?

+5
source share
8 answers

Check the configuration of the Oracle client (including, as the message says, ORACLE_HOME), check the file permissions, etc. DBI alone is unlikely to have anything to do with the problem, and I know that DBD :: Oracle is compatible with 11g libraries (at least 11g InstantClient).

+6
source

.

+3

Oracle form 10.2.0.4 10.2.0.5 Perl-CGI , error.log Apache :

DBI connect ('DB', 'user',...) failed: ERROR OCIEnvNlsCreate. ORACLE_HOME (Linux) env var PATH (Windows) / NLS, ..... OCIEnvNlsCreate. ORACLE_HOME (Linux) env var PATH (Windows) / NLS, ..! ...

:

my $ORACLE_HOME = "/usw/app/oracle/product/10.2";
$ENV{ORACLE_HOME}=$ORACLE_HOME;
+2

, , . , .

: RedHat 6.5, Oracle Instant Client 12.1, Apache 2.2

: , Oracle Instant Client, LD_LIBRARY_PATH. "", . :

# chmod o+rx INSTANTCLIENT-DIRECTORY

ORACLE_HOME LD_LIBRARY_PATH. ( "" ORACLE_HOME, , , Instant Client LD_LIBRARY_PATH ! NOT! ORACLE_HOME.) , ... , :

    failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var
    or PATH (Windows) and or NLS settings, permissions, etc.

- !

, - !

+2

#!/usr/bin/perl ( script) - perl, !

0

, : DYLD_LIBRARY_PATH Oracle instantclient. , : launchctl export

launchctl getenv variable_name OS X 10.10

.bash_profile , instanclient launchctl PATH DYLD_LIBRARY_PATH - , :

launchctl setenv PATH /path/to/instantclient
launchctl setenv DYLD_LIBRARY_PATH /path/to/instantclient
0

, Oracle, . LD_LIBRARY_PATH, LIBPATH ( AIX), DYLD_LIBRARY_PATH , , .

0
source

I also experienced the same problem. In my case, the ORACLE_HOME environment variable was wrong.

0
source

All Articles