Inserting null values into a float4 field using Perl DBI
От | Dan Rosner |
---|---|
Тема | Inserting null values into a float4 field using Perl DBI |
Дата | |
Msg-id | 39629D1A.E6C8B9CD@cascadepg.com обсуждение исходный текст |
Список | pgsql-interfaces |
Greetings! Would anyone mind educating me about how to properly insert null values into a postgresql float4 field using perl DBI? I keep getting 0 in the field, instead of a NULL value as I would expect. Background: I'm using placeholders with DBI to read in data from a file. I do this a lot, as in this example: my $sth = $dbh->prepare_cached( q{ INSERT INTO mytable (field1, field2, field3) VALUES (?, ?, ?) }) ; open (FH, "< $path") or die "Unable to open $path: $!"; while (<FH>) { chop; my ($field1,$field2, $field3) = split /,/; $sth->execute($field1, $field2, $field3); } close (FH); The sample file I'm reading has some Null values and looks like this: 1,2,3 4,,6 2,,6 7,8, 12,13,14 However, these values turn up in postgres table as 0, not NULL. When I do a select on the data read in with DBI, I get: 1,2,3 4,0,6 2,0,6 7,8,0 12,13,14 Would anyone mind telling me what I'm missing and/or point me to an example of how to do this properly. I'm using DBD::Pg 0.93 and postgres 7.02 on both NT and Linux. Thanks! Dan
В списке pgsql-interfaces по дате отправления: