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

Hi, tables looks like this...
+----------------------------+-----------------------+------+-----+--- +------+----------------+ | Field | Type | Null | Key | De +fault | Extra | +----------------------------+-----------------------+------+-----+--- +------+----------------+ | met_office_id | int(11) | NO | PRI | NU +LL | auto_increment | | observation_datetime_utc | datetime | NO | | NU +LL | | | observation_datetime_local | datetime | NO | | NU +LL | | | observation_datetime | datetime | NO | | NU +LL | | | station_id | char(4) | NO | MUL | NU +LL | | | station_name | char(25) | YES | | NU +LL | | | temp_c | decimal(4,2) | YES | | NU +LL | | | dewpoint_c | decimal(4,2) | YES | | NU +LL | | | humidity_rh | decimal(5,2) unsigned | YES | | NU +LL | | | wind_dir_compass | char(3) | YES | | NU +LL | | | wind_speed_mph | decimal(5,2) unsigned | YES | | NU +LL | | | wind_gust_mph | decimal(5,2) unsigned | YES | | NU +LL | | | visibility_metres | mediumint(8) unsigned | YES | | NU +LL | | | pressure_hpa | decimal(6,2) unsigned | YES | | NU +LL | | | pressure_tendency | char(1) | YES | | NU +LL | | | weather_type | char(2) | YES | | NU +LL | | +----------------------------+-----------------------+------+-----+--- +------+----------------+
Fields setup to default to NULL (at least I think so)

Replies are listed 'Best First'.
Re^3: Writing NULL values to a MySQL record via DBI
by GrandFather (Saint) on Feb 26, 2015 at 22:35 UTC

    As Anonymous Monk suggested, switch to using place holders instead of manifest strings in the SQL. Also, if you aren't already, make sure you are using strictures (use strict; use warnings; - see The strictures, according to Seuss). They will pick up dodgy code and run time errors such as using undef variables in inappropriate ways.

    If your problem persists try writing a little test script, maybe using SQLite instead of MySQL (because it's just a CPAN install - no server needed), that demonstrates the issue.

    Perl is the programming world's equivalent of English