Which one represents null? undef or empty string

user966588 picture user966588 · Oct 3, 2012 · Viewed 8.5k times · Source

I want to insert null in a column in a table.

Which one represents null? undef or empty string ''.

Which one should be used and Why? I know about defined and that I can check it.

But I am looking more from perspective of database.

Which one represents null more properly?

Update: I am using DBI module.

Answer

cjm picture cjm · Oct 3, 2012

DBI uses undef to represent a SQL NULL. The empty string represents an empty string.

However, some databases don't make a distinction between NULL and the empty string. Oracle is a particular offender here. DBI can't do anything about that.