On Wed, Apr 25, 2001 at 05:19:14PM +0200, Sean Carte wrote:
> I'm trying (unsuccessfully) to get DBI:Pg to insert NULL values into
> a table. The following works in psql (and dbish):
>
> 'UPDATE null_test SET dwarf_1=NULL WHERE dwarf_2='Grumpy';'
>
> It also works in a $dbh->do() statement:
>
> But when I attempt the same with placeholders:
>
> $cursor = $dbh->prepare( qq{UPDATE null_test SET dwarf_1=? WHERE
> dwarf_2=?} ) || die $dbh->errstr;
> $cursor->execute(NULL, 'Grumpy') || die $dbh->errstr;
>
> Perl complains about the bareword, NULL. Turning off strict results
> in the string 'NULL' being inserted.
>
SQL's NULL is Perl's undef.
$cursor->execute(undef, 'Grumpy') || die $dbh->errstr;
Ronald