Annotation of db/prgsrc/delt-np.pl, revision 1.1
1.1 ! boris 1: #!/usr/local/bin/perl
! 2:
! 3: use DBI;
! 4: use strict;
! 5:
! 6: MAIN:
! 7: {
! 8: my($key, $value, $addition);
! 9:
! 10: my($source, $TourId, $QId);
! 11:
! 12: print "Before connecting to the DB\n";
! 13:
! 14: my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "")
! 15: or die "Can't connect to DB chgk\n";
! 16:
! 17: print "Connected successfully\n";
! 18:
! 19: while ($source = shift) {
! 20: print "$source\n";
! 21:
! 22: my ($sth) = $dbh->prepare("SELECT Id FROM Tournaments WHERE ParentId = $source");
! 23: $sth->execute;
! 24:
! 25: while ($TourId = ($sth->fetchrow)[0]) {
! 26:
! 27: my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions
! 28: WHERE ParentId = $TourId");
! 29: $sth->execute;
! 30:
! 31:
! 32: while ($QId = ($sth->fetchrow)[0]) {
! 33:
! 34: #my ($sth) = $dbh->prepare("DELETE FROM Lines WHERE Id = $QId");
! 35: #$sth->execute;
! 36:
! 37: my ($sth) = $dbh->prepare("DELETE FROM Questions WHERE QuestionId = $QId");
! 38: $sth->execute;
! 39:
! 40:
! 41:
! 42: }
! 43:
! 44: my ($sth) = $dbh->prepare("DELETE FROM Tournaments WHERE Id = $TourId");
! 45: $sth->execute;
! 46:
! 47: }
! 48:
! 49: my ($sth) = $dbh->prepare("DELETE FROM Tournaments WHERE Id = $source");
! 50: $sth->execute;
! 51: }
! 52: $dbh->disconnect;
! 53: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>