I find a common operation is to execute a statement that you expect to return
at most one row and then fetch that row.  I've found it convenient to combine
these two calls into one:

  $res = $sth->executerow_foo(@bind);

equivalent to:

  $sth->execute(@bind);
  $res = $sth->fetchrow_foo();
  $sth->finish;

Ideally, after getting the first row, it could additionally check if there are
more rows to fetch and complain if there are.  It could also return a
different value to indicate error condition, or just raise an error.

I've found such a function useful and often define it myself.  I realize it's
similar to $dbh->selectrow_foo($sth, undef, @bind), but with better-looking
syntax, more checking, and also finishes the current execution.  If other
people would find it useful, it might be a nice addition to DBI.

Thanks,
:-Dylan

Reply via email to