in reply to DBI - Handling NULL values
A related issue is the difference between the SQL keyword NULL (which never has quotes around it) and the literal string 'NULL' which, because it has quotes around it, is a string value, not a NULL value. So:
This uses the SQL keyword NULL to insert a NULL into the table:
$dbh->do("INSERT INTO x VALUES (1,NULL)");
But, this inserts the literal string N-U-L-L into the table:
$dbh->do("INSERT INTO x VALUES (1,'NULL')");
And when using placeholders.
This inserts a NULL value:
$sth->execute(1,undef);
But this inserts the literal string N-U-L-L:
$sth->execute(1,'NULL');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: DBI - Handling NULL values
by McDarren (Abbot) on Sep 29, 2005 at 07:03 UTC |