in reply to Re^5: Writing NULL values to a MySQL record via DBI
in thread Writing NULL values to a MySQL record via DBI

I might not be getting this fully - I'm trying to go through the cpan documentation for DBI. If you want to insert a NULL value for a particular field you use 'undef' but what if in my case you don't know whether the field will be undefined when you extract if from the CSV file? I need the variable (e.g. '$file_temp_c' from the original code block I included earlier) to be equal to either a value if populated or 'undef' if the CSV file did not have a value. I can test the variable and they do indicate they are undefined but, at least in my original code they do not translate to NULL in the MySQL table - hope this makes sense and is possible.
  • Comment on Re^6: Writing NULL values to a MySQL record via DBI

Replies are listed 'Best First'.
Re^7: Writing NULL values to a MySQL record via DBI
by Anonymous Monk on Feb 26, 2015 at 23:25 UTC
    The first argument is your SQL statement. The second argument is a special thing. Just ignore it and use what i provided until you understand. The remaining arguments are your values you want inserted.

    Finish writing the code i provided and run it and see what happens. Let us know.

      Ok, Thanks - really appreciate your help. Need to fix a few other parts of my code before I can run it again - which I'll do tomorrow as it's late here! I'll update the code with that you have written and let you know - Thanks again.
        You are welcome. Thank you in return for simply having the desire to write more secure (and maintainable) code. :)

        If you have more questions i recommend starting a new thread tomorrow, and reference this one to let others know what advice has been given so far. Good luck!