in reply to Retrieving number of updated rows in a database

Two ways:
Either call  my $numberofrows = $stHandle->rows(); after executing your statement, or bundle it all in to one statement with:
my $numberofrows = $dbh->do("UPDATE .. ");
(Which works if you don't need to bind parameters)
Or even: my $numberofrows = $dbh->do($stHandle); instead of execute.

C.
(Its all in the perldoc for DBI)

Replies are listed 'Best First'.
Re: Re: Retrieving number of updated rows in a database
by Cabrion (Friar) on Feb 02, 2003 at 14:16 UTC
    Just to add my two cents. . .

    $numberofrows will be '0E0' in the event that no rows were updated, but the query was sucessful. It will be '0' if the query failed (i.e. bad SQL).

    '0E0' is a value that evaluates to true in a boolean context, but acts as the number 0 in a numeric context. I always thought that was quite interesting.

    Updated: Typos fixed.

Re: Re: Retrieving number of updated rows in a database
by rdfield (Priest) on Feb 02, 2003 at 18:22 UTC
    It also works with bind parameters:
    $numberofrows = $dbh->do("update...",undef,@bind_params);
    (where undef is a placeholder for any additional attributes, e.g. AutoCommit, RaiseError)

    rdfield