in reply to Re: Perl DBI (sybase) rapidly delete large number of records
in thread Perl DBI (sybase) rapidly delete large number of records
You actually don't need the if/else block, as splice will return all of the remaining records in the 'else' case. I use the following:
(I probably don't need to rebuild the sql statement each iteration of the loop, only the first/last ones, but it's rare that I delete more than 100 at a time)
while ( @delete ) { my @files = splice( @delete, 0, 100 ); my $sth_delete = $db->prepare( 'DELETE FROM SECCHI WHERE filep +ath IN (' . join ( ',', ( ('?') x @files ) ) . ')' ); $sth_delete->execute( @files ) or warn "Couldn't delete files"; }
|
|---|