in reply to DBI - Insert NULL value into DB

Suggested by DBI:

while (($id,$value) = $hStatement->fetchrow_arrayref) { foreach (($id,$value)) { $_ = '' unless defined }; ...

Update: in Informix at least, this does not work. An empty string does not equate to NULL. Also, I don't get any warnings when updating a table using a undefined variable.

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Replies are listed 'Best First'.
Re^2: DBI - Insert NULL value into DB
by hippo (Archbishop) on Aug 24, 2016 at 14:07 UTC

    Won't that mean that the second table has no NULLs in it and is therefore not a real copy of the first table?

      Good point - this would be something to test, if the DB interprets an empty string as a NULL value.

      But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)