Subject: | cannot locate sqlldr binary even though it is clearly in the user accounts PATH settings |
I have been trying to use the Oracle::SQLLoader module to write some backend database functions, i.e updates etc in conjunction with the DBI module. However even though the correct path to the sqlldr binary is clearly visible in the user account PATH variable the module cannot find the sqlldr binary. Example of my code:
#!/usr/local/bin/perl
use strict;
use Cwd 'chdir';
use Oracle::SQLLoader qw/$CHAR $INT $DECIMAL $DATE $REPLACE/;
#########var#############
my $ldr;
my $sql_path = '/foo/bar/oof/rab/datafiles/something.tab.ncb';
my $logfile = 'ebook.log.test.ncb.rr';
my %Globals = (
LOADMODE => 1,
INFILE => "/foo/bar/oof/rab/datafiles/something.tab",
USER => "foo",
PASS => "bar",
TERMINATOR => "\t",
);
my $REPLACE;
#########code############
&logger('Initialise test...');
$ldr = &SQLload;
my $findsqlldr = $ldr->findProgram('sqlldr');
if (! defined($findsqlldr)) { die "sqlldr could not be found\n" }
$ldr->addTable(table_name => 'ebook_creation');
$ldr->addColumn(column_name => 'isbn');
$ldr->addColumn(column_name => 'format_code');
$ldr->addColumn(column_name => 'answer_code');
$ldr->addColumn(column_name => 'answer_month');
$ldr->executeLoader() or &logger("Problem executing sqlldr: $!");
&myexit(2);
########functions########
sub logger {
# Use: &logger("<message>");
open LOGFILE, ">>$logfile";
print LOGFILE "$_[0]\n";
close LOGFILE;
}
sub myexit {
# Use: &myexit(error code);
my $rcde = $_[0];
if ($rcde = 1) {
$rcde = "Fatal error caused exit of script.";
}
elsif ($rcde = 2) {
$rcde = "Successful $Globals{RUN} run.";
}
&logger($rcde);
exit;
}
sub SQLload {
# Use: $ldr = $SQLLoad;
my $ldr;
my $REPLACE;
&logger("Opening sqlldr...");
if (defined($Globals{LOADMODE})) {
$ldr = new Oracle::SQLLoader (
infile => $Globals{INFILE},
username => $Globals{USER},
password => $Globals{PASS},
terminated_by => $Globals{TERMINATOR},
loadmode => $REPLACE,
);
}
return $ldr;
}
Any help would be greatly appreciated.