in reply to DBD::CSV empty fields problem on RedHat / Perl 5.8.

I can replicate this error on windows (Win XP 5.1; Perl 5.6.1). However, the syntax below (using place-holders) works correctly for me. I often find that inserting a NULL into the leading field of a database table causes problems when not using place-holders. Does this work for you?

use DBI; use strict; my $dbh = DBI->connect("DBI:CSV:f_dir=./;"); my $param1 = undef; my $param2 = 'test'; my $sql_create = ' create table mytable( field1 text, field2 text )'; my $sql_insert = ' INSERT INTO mytable( field1, field2 ) VALUES (?,?)'; my $sth_insert = $dbh->prepare($sql_insert); $dbh->do($sql_create); $sth_insert->execute($param1, $param2); print "field1=",$dbh->selectrow_array("select field1 from mytable");
Hope this helps,
-Tats

Update:
DBD::DSV 0.2002
DBI 1.30

Replies are listed 'Best First'.
Re: Re: DBD::CSV empty fields problem on RedHat / Perl 5.8.
by benn (Vicar) on Jun 09, 2003 at 18:14 UTC
    Indeed - that works fine. We're using placeholders everywhere else, and only found this due to an 'optimisation' of the "update mytable set ".join(",",map {"$_=".$dbh->quote($cgi->param($_))} @fields) variety. Interesting that it's Windows/5.6 - as I said, Debian/5.6 was fine, as was Windows/5.8. Good to have it confirmed though :)

    Thanks, Ben.