On 2008-07-01 01:37:01 -0400, Ramesh Thangamani via RT wrote: > Queue: DBI > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=36395 > > > On Tue Jun 24 17:17:23 2008, TIMB wrote: > > The DBI is acting as defined. It's not a bug. > > You should avoid using an array to pass arguments to execute(). > > I could still see the following examples mentioned in the documentation > in CPAN where we are passing an array to execute method(). Please > comment on this. > > $rv = $sth->execute or die $sth->errstr; > $rv = $sth->execute(@bind_values) or die $sth->errstr;
Which means that exeute takes a list of bind values. It doesn't
necessarily mean that it is good style to use an actual array.
But I disagree with Tim here. There are many situations where using an
array is the right thing to do - especially if you are constructing sql
statements with a variable number of placeholders on the fly it is IMHO
the only sane way.
I think it is unfortunate that execute with zero parameters means
something different from execute with non-zero parameters and that there
is no way to distinguish zero parameters from an array with with zero
elements, but that can't be helped: Changing the former would break lots
of existing code, and the latter is a fundamental property of Perl5.
In practice I've never run into this problem. While I have occassionally
constructed queries where the number of placeholders and the size of the
array were not equal, I don't remember ever ending up with an empty
array. I did forget the parameter list a few times (i.e., $sth->execute
instead of $sth->execute($x, $y)) ...
hp
--
_ | Peter J. Holzer | If I wanted to be "academically correct",
|_|_) | Sysadmin WSR | I'd be programming in Java.
| | | [EMAIL PROTECTED] | I don't, and I'm not.
__/ | http://www.hjp.at/ | -- Jesse Erlbaum on dbi-users
pgp21zqhqE25d.pgp
Description: PGP signature
