--- db/prgsrc/deletefiles.pl 2001/07/28 17:23:02 1.2 +++ db/prgsrc/deletefiles.pl 2001/07/28 21:21:29 1.4 @@ -28,7 +28,7 @@ createindex.pl(1), updatedb.pl(1), updat Boris Veytsman -=head1 $Id: deletefiles.pl,v 1.2 2001/07/28 17:23:02 boris Exp $ +=head1 $Id: deletefiles.pl,v 1.4 2001/07/28 21:21:29 boris Exp $ =cut @@ -38,7 +38,7 @@ use DBI; MAIN: { - my $USAGE="Usage: deletefiles.pl [-y|-n] file file file...\n"; + my $USAGE="Usage: deletefiles.pl file file file...\n"; my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") or die "Can't connect to DB chgk\n"; foreach my $file (@ARGV) { @@ -46,8 +46,12 @@ MAIN: select Id,ParentId,QuestionsNum from Tournaments where Type='þ' and FileName='$file'"); $sth->execute; + if (!$sth->rows) { + print STDERR "File $file is not found in the database\n"; + next; + } while (my ($Id,$ParentId,$QuestionsNum) = $sth->fetchrow) { - print "Deleting $file Id=$Id, $QuestionsNum questions\n"; + print STDERR "Deleting $file, Id=$Id, $QuestionsNum questions\n"; UpdateParents($dbh,$ParentId,$QuestionsNum); UpdateChildrenAndDie($dbh,$Id); }