In particular, I need to delete some rows from the table, iterating over all rows in the table. Does DBI have something like an updatable result set in Java? So, if I am something like:
$query_all = $dbh->prepare("select Id, X, Y, Z from MyTable"); $delete = $dbh->prepare("delete from MyTable where Id = ?"); $query_all->execute(); while ( my @res = $query_all->fetchrow_array() ){ my ($id, $x, $y, $z) = @res;
... its OK?
To give some context, I delete duplicate rows that have the same values ββfor columns X, Y, Z, and leaving only one row in each case (the first one found). If that was all I was doing, I would just set a unique index for these three columns to eliminate duplicates, but I also need to delete a row from another table for each duplicate deleted from MyTable .
In the end, I wrote a script to identify and collect all the identifiers for the rows that I need to delete into an array, and then iterate over this array, deleting the corresponding rows from both tables. However, I am still interested in finding the answer to the original question. If I get time, I will try to answer it myself, but if someone already knows that I would like to hear it.
source share