It sounds like you are describing two existing methods: selectrow_arrayref selectrow_hashref
which are in the perldocs under handle-methods. See: http://search.cpan.org/~timb/DBI-1.38/DBI.pm#Database_Handle_Methods Paul > -----Original Message----- > From: Dylan Alex Simon [mailto:[EMAIL PROTECTED] > Sent: Sunday, November 16, 2003 4:00 AM > To: [EMAIL PROTECTED] > Subject: new function suggestion: $sth->execute + fetch single row > > > 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
