my $count = $sth->execute; if (! $count) { die "Couldn't execute >>$sql<< : " . $sth->errstr; }; if ($count == 0) { print "No rows were affected."; } else { while (my $pointer = $sth->fetchrow_hashref) { ... do magic ... }; }; #### my $res = $sth->execute; if (! $res) { die "Couldn't execute >>$sql<< : " . $sth->errstr; }; my $rows = 0; while (my $pointer = $sth->fetchrow_hashref) { ... do magic ... $rows++; }; if (! $rows) { print "No rows were affected."; };