while ($row = $csv->getline ($fh)) { $SQL1 = "Insert into TAB1 (sample_date, server, first, n1, n2) values (?,?,?,?,?)"; $sth = prepare($SQL1) $sth -> execute($row[0], $row[1], $row[2], $row[3], $row[4]); if ($sth->err) { $rc=0; $dbAgent->rollback(); close $fh; } $rc++; } close $fh; $dbAgent->commit;