I am looping through a batch of data. I am creating a output header and detail record for each record that has a status of 112584.
After I creat the header and detail output records I want to change the status field from 112584 to 112586.
I do not want to effect the loop I am in. I think I have the code correct but I was wondering if somebody that has done this could review this and see if I have it correct.
After I creat the header and detail output records I want to change the status field from 112584 to 112586.
I do not want to effect the loop I am in. I think I have the code correct but I was wondering if somebody that has done this could review this and see if I have it correct.
Code:
$dbh=DBI->connect($dsn, $user, $pass) or die;
$sth = $dbh->prepare("SELECT * FROM CVIS.LAW_INV_ITEM_TRX")
or die "Couldn't prepare statement: " . $dbh->errstr;
@data;
$rv = $sth->execute or die "Couldn't execute: " . $dbh->errstr;
open(OUT, ">>$vPath1$vName1") or die "Couldn't open: " . $dbh->errstr;
## Loop through each line of the table
while (@data = $sth->fetchrow_array()) {
... other code ...
if ($data[8] eq 112584) {
## map and load the header line
$sLin2 = $vComp . $vICLoc . "40" . "IS" . $vDesc
.= $vSeq . $vSeq . $vCRD1 . $sNStri20 . $vICLoc
.= $sNStri313 . "\n";
print OUT $sLin2;
## map and load the detail line
$sLin3 = $vComp . $vICLoc . "40" . "IS" . $vDesc
.= $vLine . $vSeq . $vItem . $vQty . $vQtySign
.= $sNStri36 . $vSUOM . $sNStri260 . "\n";
print OUT $sLin3;
$sLin4 = $data[8] . "\n";
print $sLin4;
## update the TRX_STATUS for this record to 112586 export completed
$st2 = $dbh->prepare("UPDATE CVIS.LAW_INV_ITEM_TRX
SET $data[8] = 112586
WHERE $data[10] = $vSysTrxId
$st2->execute or die "Could't update data: " . $DBH->errstr;
}
}
$sth->finish;
$dbh->disconnect();