I am trying to test a table for a entry to see if it is there before I write the record.
This code is failing to work. I thought that if the record was not found I would have an error, so errstr would be longer than 0.
Is there a better way to check if a record is found?
Code:
$st2 = $dbh->prepare("SELECT * FROM procure.INVOICE_BLT WHERE
company = '" . $vCompstr . "' and
vendor = '" . $vVendor . "' and
invoice = '" . $vInvoice . "'")
or die "Couldn't prepare statment 2: " . $dbh->errstr;
my @dat2;
my $r2 = $st2->execute
or die "Couldn't execute statement 2: " . $st2->errstr;
if (length(errstr) eq 0) {
print leaInv $sLine;
$query = "INSERT INTO procure.INVOICE_BLT (company, vendor,
invoice) VALUES
('"."$vCompstr"."',
'"."$vVendor"."',
'"."$vInvoice"."')";
$dbh->do($query) or die "DBI::errstr";
}
This code is failing to work. I thought that if the record was not found I would have an error, so errstr would be longer than 0.
Is there a better way to check if a record is found?