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."; };