in reply to Writing NULL values to a MySQL record via DBI

What does the the met_office_raw_data table look like.
Using mysql client you can use the describe command like this.

mysql> describe test; +-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id | int(11) | NO | PRI | 0 | | +-------+---------+------+-----+---------+-------+ 1 row in set (0.00 sec)

The columns to look at are 'Null' (YES/NO) and the 'Default' values

poj

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

      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