On Mon, Aug 20, 2001 at 02:16:13PM -0230, Chad House wrote:
: I've run into a peculiar bug when running some code under mod_perl
: that doesn't show up outside the mod_perl environment.
: 
: I have some insert code that looks like this:
: 
: 
:   my $sth = $dbh->prepare(q{insert into metadata (id, property, value)
:                             values (?,?,?)}) or die $dbh->errstr;
: 
:   my $count = 0;
:   while (my ($property, $value) = each %{$self->{_meta}}) {
:     $sth->execute($self->{_id}, $property, $value) or return;
:     $count++;
:   }

We've had a problem similar to this.  By default, the DBI seems to
treat numbers as INTEGER fields, which don't need quoting.  Our
experience has been that it makes this determination on the first call
to execute() and then caches it.  So, if you're actually putting in
mixed data (INTEGER and CHAR or VARCHAR data), then you're playing
Russian roulette with your data.  You experience it under mod_perl
because your handle is most likely remaining in memory.

: If I do this instead:
: 
:   $sth->bind_param(1, $self->{_id});
:   $sth->bind_param(2, $property);
:   $sth->bind_param(3, $value, {TYPE => SQL_VARCHAR} );
: 
: It works, but ... I shouldn't have to do that.
: 
: It's not clear to me what's going wrong here. Has anyone experienced
: something similar, or have any insight into what's happening here?

Right, in this case, you tell the query the type each time, so there's
no mistake.

* Philip Molter
* DataFoundry.net
* http://www.datafoundry.net/
* [EMAIL PROTECTED]

Reply via email to