in reply to DBI Inserting undef as literal string 'null'
I'm presuming you are using DBD::ODBC although you did not say so.
To insert a NULL you bind an undef - that should work. If that does not work for you then you are either not binding an undef or your DBD or ODBC driver is faulty. However, when you say the column contains 'null' afterwards how did you ascertain this - i.e., what did you use to view this column?
You may be able to use ParamValues after the execute to see what you are inserting but not all DBDs support it - though should and DBD::ODBC certainly does so long as you have not got an ancient version.
Another alternative for seeing what you are doing is using DBIx::Log4perl which shows bound parameters and a whole lot more. However, before you go down this route I'd suggest you examine carefully what you are binding. Add Data::Dumper and dump those "@values" before the call to execute.
BTW, you should not need to use that finish - see the DBI pod on finish.
You might want to look up the chomp function instead of you method of removing newlines.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: DBI Inserting undef as literal string 'null'
by marmanold (Novice) on Feb 23, 2010 at 21:32 UTC | |
by mje (Curate) on Feb 24, 2010 at 08:45 UTC |