SergioQ has asked for the wisdom of the Perl Monks concerning the following question:
I have the function below that I use in perl. I build the command elsewhere as it could be a SELECT, INSERT, et al.
In one instance I am using the function to insert new records into my MySQL table. And generally it works. But occasionally it will fail on an insert, and I was hoping I could find out what the actual reason an insert failed. To be clear I am inserting over a thousand records into this table, and most work.
I even had my perl script print out the actual command that returns a nil on the result, and then I copy and paste that exact command into MySQL's terminal where it works. So even more reason to get the exact reason it failed.
I should add that the table has no index, and no unique fields.
#from elsewhere in my code ... $db=DBI->connect('DBI:mysql:invoices',[username],[password], { RaiseEr +ror => 0, AutoCommit => 1 }); #$rawDB is set to the table name my $insertCommand = "INSERT INTO $rawDB (sheet_no, sheet_name, item, c +oll, roww, category) VALUES ('$currentSheet', '$sheetname', '$cellData', '$curcol', '$curro +w', '');"; my $result = insertItem($insertCommand); #.... sub insertItem { (my $insertCom) = @_; $dbHandle=$db->prepare($insertCom); my $result = $dbHandle->execute(); return $result; }
|
---|