Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by Anonymous Monk
on Feb 26, 2015 at 22:59 UTC ( [id://1118014]=note: print w/replies, xml ) Need Help??


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

Please read the documentation. The undef is very necessary here and refers only to the value for the second argument being passed to the method do. Explaining exactly what that argument is for is difficult, at best. Otherwise you are very very close to understanding how this works.
  • Comment on Re^5: Writing NULL values to a MySQL record via DBI

Replies are listed 'Best First'.
Re^6: Writing NULL values to a MySQL record via DBI
by ureco (Acolyte) on Feb 26, 2015 at 23:12 UTC
    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.
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1118014]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found