rows()
$sth->rows()This function returns the number of rows affected by the last
statement handle executed. It works with UPDATE,
INSERT, and DELETE dependably.
It doesn’t work effectively with SELECT statements
unless all rows in a table are selected. If the number of rows is
unknown, –1 is returned. There are no arguments to this method. Here
is an example:
...
my $sql_stmnt = "UPDATE books SET author = 'Robert B. Parker'
WHERE author = 'Robert Parker'";
my $sth = $dbh->prepare($sql_stmnt);
$sth->execute();
my $change_count = $sth->rows();
print "$change_count rows were changed.";This program displays the following when run:
2 rows were changed