I am reading one table and creating an array that will be used many times.
The second Select returns values, if the pay-sum-grp value is found in the array I need to add the wage-amount to the variable $vGrossRG. I loop through all of the entries in this table for any match to a value in the array RG2.
The grep statement
if (grep {$_ eq $Element} @RG2) {
my $vGrossRG = ($vGrossRG + $dat9e[1]);
}
}
appears to not be working correctly.
I know I am not the expert that many of you are. Can somebody please tell me what I am am doing wrong?
The second Select returns values, if the pay-sum-grp value is found in the array I need to add the wage-amount to the variable $vGrossRG. I loop through all of the entries in this table for any match to a value in the array RG2.
The grep statement
if (grep {$_ eq $Element} @RG2) {
my $vGrossRG = ($vGrossRG + $dat9e[1]);
}
}
appears to not be working correctly.
I know I am not the expert that many of you are. Can somebody please tell me what I am am doing wrong?
Perl:
## read table LAWSON.EMPLOYEE and process each entry
use DBI;
$dbh=DBI->connect('dbi:ODBC:LawDEV', $user, $pass,
{RaiseError => 1, odbc_cursortype => 2}) or die;
## build the current array of RG2 pay-sum-grp values
$st9a = $dbh->prepare("SELECT PAY_SUM_GRP FROM PSGRELATE WHERE
COMPANY = '" . $vComp . "' and
PAY_CLASS = 'RG2'") or die "select 9a: " . $db9a->errstr;
@dat9a;
@RG2;
$r9a = $st9a->execute or die "Couldn't exe 9a: " . $st9a->errstr;
while (@dat9a = $st9a->fetchrow_array()) {
push(@RG2, $dat9a[0]);
}
$st9a->finish;
$string1 = join(", ",@RG2);
## print $string1 . "\n";
$st9e = $dbh->prepare("SELECT PAY_SUM_GRP, WAGE_AMOUNT
FROM PRTIME WHERE
COMPANY = '" . $vComp . "' and
EMPLOYEE = '" . $vEmp . "' and
CHECK_ID = '" . $vChkId . "'")
or die "select 9e: " . $db9e->errstr;
my @dat9e;
my $Element = $dat9e[0];
my $vGrossRG = 0;
my $r9e = $st9e->execute or die "Couldn't exe 9e: " . $st9e->errstr;
while (@dat9e = $st9e->fetchrow_array()) {
if (grep {$_ eq $Element} @RG2) {
my $vGrossRG = ($vGrossRG + $dat9e[1]);
}
}
$st9e->finish;
$Tag01 = "<GrossBaseEarnings>";
$Tag02 = "<\/GrossBaseEarnings>";
$sLine = $Tag01 . $vGrossRG . $Tag02 . "\n";
print $sLine;