in reply to Dont understand differences between these 2 functions!

report1

report2

The different assumptions impose different validation requirements on the caller.
The number of queries affects performance.

Update: report3 uses the best features of report1 and report2.

sub report3 { my $table = shift @_; my @statusids = @_; my $sql = " SELECT statusid, COUNT(statusid) FROM $table WHERE statusid IN (". join(',', ('?')x@statusids) . ") GROUP BY statusid "; my $sth = $DBH->prepare($sql); $sth->execute(@statusids); while (my ($statusid, $count) = $sth->fetchrow_array) { print "$statusid = $count\n"; } }