I am trying to connect to Oracle using Perl.
I am trying to connect from a Windows XP machine that has Perl installed. I also have downloaded Oracle SQL Developer and Oracle Instant Client. I can connect to the Oracle DB using Oracle SQL Developer using the TNS connection type.
I use the following Perl.
use DBI;
$db=DBI->connect( "dbi:Oracle", "username", "password" ) or die "Can't connect $DBI::errstr\n";
I get the following error message.
DBI connect('','username',...) failed: ERROR
OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID) Check NLS settings etc. at oracle2.pl line3
Cant connect to database ERROR OCINlsEnvironmentVariableGet(OCI_NLS_CHARSET_ID) Check NLS settings etc.
Do I need to do anything with Oracle Instant Client because it does not have an installer? Is there something else that needs to be configured in Perl?
Are there any variables I need to set at the beginning of the Perl to link to either SQL Developer or Instant Client?
I used a different method to connect Perl to an Oracle DB. I used SQLPlus instead of DBI. This is a command line utility from Oracle that can be called from Perl. Below is a sample of my code. The test.sql file can contain one or multiple queries and must end with exit.
my $connect_string = 'username/password@server'; # connection to the DB
my $file = 'test.sql'; # location of SQL file. The file must end with "exit"
my $sqlcmd = "sqlplus -S $connect_string \@$file"; # sqlcommand
system $sqlcmd; # executes command