This is often a quoting issue. For example, your query may look like this:
INSERT member (last, first)
VALUES(NULL, "chromatic");
and your script like this:
$last = "NULL";
$first = "chromatic";
$query =
qq {
INSERT member (last, first)
VALUES ($last, $first)
};
$rows = $dbh->do($query);
Printing your $query would reveal that $last and $first are not being quoted.
The solution is to use something like this:
$last = $dbh->quote("NULL");
$first = $dbh->quote("chromatic");
or this:
$query =
qq {
INSERT member (last, first)
VALUES (?, ?)
};
$rows = $dbh->do($query, undef, $last, $first);
Originally posted as a Categorized Question.