in reply to rows affected inside a transaction

This is not an ideal solution, but...

Since you're in a transaction, you don't have to worry about a race condition. As such, you can query for the matching records before you delete them.

my $suffix = 'FROM table WHERE blah blah'; my ($to_be_deleted) = $dbh->selectrow_array( "SELECT count(*) $suffix" ); $dbh->do( "DELETE $suffix" );

The first problem with this is performance. You'll be going to these same records twice. If it's a huge table, and the condition causes a full table scan, this is going to be really painful.

The second problem is that it's possible for $suffix to work fine for the "SELECT", but not for the "DELETE". That's not a huge problem, I think, because it will abort the transaction. That is, it'll fail instead of lie. I could be wrong, however. Not knowing what kind of SQL you have in $sth, I don't know if this is a potential issue.

Replies are listed 'Best First'.
Re^2: rows affected inside a transaction
by x5150 (Acolyte) on May 14, 2008 at 18:43 UTC
    Found out there were some DELETE and SELECT triggers on those tables that didn't actually delete the data but looked like it did.