Well I am not sure what you are doing.  Where is $val1 coming from?
undefined values cause NULL values to be inserted, unless the field has a
default, which the db will take care of and insert the default value.

Ilya

> -----Original Message-----
> From: Jeff Thies [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 09, 2001 5:51 PM
> To: [EMAIL PROTECTED]
> Subject: undefined values in placeholders
>
>
> I'm doing something like this (MySQL):
>
> my $sql=q{replace into styles(field1,field2) values(?,?)};
> my $sth=$dbh->prepare($sql);
>
> sub enterStyles{
> my($val1,$val2)=@_;
> $sth->execute($val1,$val2) || die "Cannot execute: $DBI::errstr\n";
> }
>
> What I've found is that if $val1 is undefined, that the execute will be
> succesfull and the inserted value will be 0.
>
> The *next* execute will fail and the error message will return an error:
> unknown field value checked (that is the value passed as the param).
>
> Is there something I should know about passing undefined values to
> placeholders (not something I plan on doing often!). That seemed to me
> to be strange behaviour. Is that expected DBI behaviour or a quirk in
> MySQL?
>
> Jeff

Reply via email to