http://www.perlmonks.org?node_id=192434


in reply to Re^2: DBD::mysql Unusual Behavior
in thread DBD::mysql Unusual Behavior

The concern is that the value will be undefined which is going to generate warnings if used.

Eh, no. Not in this particular case, anyway. The thing is that DBI's placeholder mechanism will convert every undef into the unquoted string "NULL", so that

INSERT INTO FOO (foo) VALUES (?)
will effectively mean
INSERT INTO FOO (foo) VALUES (NULL)

And some people's database setup will complain about that, if the field isn't allowed to be NULL. Personally, I like NULLs in my databases, for values that indeed have no value.

Replies are listed 'Best First'.
Re^4: DBD::mysql Unusual Behavior
by tadman (Prior) on Aug 23, 2002 at 20:39 UTC
    The NULL fields actually consume an astounding extra bit per record, so while they're convenient and all, if the difference between "empty" and NULL is trivial, it's often easier to just throw in an empty value.

    Since the column in question was not allowed to be NULL, you're required to check before INSERTion.