tags:

views:

299

answers:

1

I am getting 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 is as follows:

#!/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();
}

Anyone seen this problem before?

+4  A: 

Check your Oracle client configuration (including, as the message says, ORACLE_HOME), check file permissions, etc. It's unlikely that DBI per se has anything to do with the problem, and I know for a fact that DBD::Oracle is compatible with the 11g libraries (at least the 11g InstantClient).

hobbs
[Exhaustive troubleshooting information](http://search.cpan.org/dist/DBD-Oracle/) - start with the files `README` and `README.help.txt`.
daxim
If I set ORACLE_HOME to the 10g instance, it's able to connect to the 11g database, however if I set ORACLE_HOME to the 11g instance I get the error...
John
OK so ORACLE_HOME is changed, if there are references to the 10g binaries in your PATH are you resetting those also to their 11g counterparts as well?
David Mann