I'm guessing that when a field is empty in your CSV file, then the method $csv->fields puts an empty string value (e.g. "") in the corresponding element in your @data array (not an undef value).
If so, you are going to have to detect for this condition and change it to an undef before binding with bind_param. Undef will cause a null to be inserted. In general, you would need to do this to all fields that you want to represent as null, when they are represented as empty fields in the CSV input. -----Original Message----- From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 16, 2005 9:18 AM To: Ronald J Kimball; [email protected] Subject: RE: NULL field matching problem... I thought about that after I hit the send button. Here is the INSERT code... my $sth = $dbh->prepare("INSERT INTO AllMid_Data VALUES(?".(",?" x 21).")") or print "Error with INSERT _prepare_ $DBI::errstr\n"; my $test = $dbh->prepare(qq{SELECT * FROM AllMid_Data WHERE CPU_DNS = ? AND CPU_Hostname = ?}); while (my $file = <CSV>) { # Next two lines parse the CSV data from AllMid my $line = $csv->parse($file); my @data = $csv->fields($file); $test->execute ($data[4], $data[14]); my $rows = $test->rows; if ($rows == 0) { # print "Entry not found. Inserting into database. \n"; # Testing line $sth->bind_param(1, undef); $sth->bind_param($_+2, $data[$_]) foreach 0..20; $sth->execute() or print "Data insert failed.";
Brian Campbell (E-mail).vcf
Description: Binary data
