KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The following code seems to be just too much, for getting a single count value. Is there a better, recommended way to fetch a single COUNT value using plain DBI? sub get_count { my $sth = $dbh->prepare("SELECT COUNT(*) FROM table WHERE..."); $sth->execute( @params ); my $($count) = $sth->fetchrow_array; $sth->finish; return $count; } This is shorter, but I still have two statements. sub get_count_2 { my $ar = $dbh->selectall_arrayref("SELECT ...", undef, @params) return $ar->[0][0]; }
Tags (comma-separated)
Save Edits
Cancel