NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED] wrote:
> 
>       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.";

I assume you're using Text::CSV or Text::CSV_XS to parse the file.  The code
that sets $csv would be helpful as well.

I tested loading your sample line with Text::CSV_XS, and @data contained an
empty string, as expected.

I would check your database schema, that seems to me like the most likely
culprit.  Make sure there are no triggers on the table that could set the
value to 0.

You could also try writing a one-off script that inserts a hard-coded row
containing a NULL value.

Ronald


Reply via email to