I start by opening a csv file to get $field[3], which works. Then I do a select to get a value from the database.
I don't get a SQL error or a compile error. The programs appears to work just fine, but I get no data from the select.
Can somebody help me figure out what I did wrong?
I don't get a SQL error or a compile error. The programs appears to work just fine, but I get no data from the select.
Code:
#!/usr/bin/perl -w
#### program variables
if ($ENV{'PRODLINE'} eq "ocfp") {
$sys = "ocfp";
$dbsys = "lawocfp";
}
else {
$sys = "ocft";
$dbsys = "lawocft";
}
## variables
$LAWDIR = "/usr/lawson/lawson/";
$vName1 = "/interface/spd_lawsonx.csv";
$vName2 = "/interface/lawson_sms.csv";
$Company = "0120";
$Location = "CS ";
$user = "procure";
$password = "*********";
$dsn = "DBI:Oracle:host=$dbsys;sid=$dbsys";
use DBI;
$connect = DBI->connect($dsn, $user, $password) or die "$DBI::errstr";
open(IN, "$LAWDIR$sys$vName1") or die 'Could not open input file';
open(OUT, ">$LAWDIR$sys$vName2") or die 'Could not open outfile';
$line=<IN>;
foreach $line (<IN>) {
chomp;
@field = split(/,/, $line);
$Item = $field[3];
$query = "SELECT ITEMMAST.DESCRIPTION, ITEMMAST.STOCK_UOM
FROM LAWSON.ITEMMAST
WHERE ITEMMAST.ITEM = '" . $Item . "'";
$query_handle = $connect->prepare($query);
@res = $query_handle->execute();
$Str1 = "desc: " . $res[0] . " uom is: " . $res[1] . "Item is: " . $field[3];
print $Str1;
$field[4] = $res[0];
$field[5] = $res[1];
print OUT join(',', @fields), "\n";
}
close(IN);
close(OUT);
Can somebody help me figure out what I did wrong?