Perl DBI doesn't work with Oracle 11g

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-26T15:23:46Z Indexed on 2010/05/27 9:21 UTC
Read the original article Hit count: 557

Filed under:
|
|

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?

/john

© Stack Overflow or respective owner

Related posts about perl

Related posts about Oracle