Transaktionen bei MySQL II

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

tfilldb.pl
$db->commit;
eval {
   my $tuple = join(", ", ("?") x $cols);
   my $st = $db->prepare(qq{
      insert into $table values ($tuple)
   });
   while(<>) {
      chomp;
      if ($strip_comments) {
         next if /^\s*#/;
         next if /^\s*$/;
      }
      my @tuple = split /$delim/, $_, $cols;
      $st->execute(@tuple);
   }
};
if ($@) {
   $db->rollback;
   print STDERR "$cmdname: transaction aborted: $@\n";
} else {
   $db->commit;
}

cordelia$ perl tfilldb.pl -d: `pwd`/testdb Abteilungen \
> 3 abteilungen 2>&1 | fold -w55
DBD::mysql::st execute failed: Duplicate entry 'AngAna'
 for key 1 at tfilldb.pl line 38, <> line 2.
tfilldb.pl: transaction aborted: DBD::mysql::st execute
 failed: Duplicate entry 'AngAna' for key 1 at tfilldb.
pl line 38, <> line 2.

cordelia$

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1996 - 2003 Andreas Borchert, in HTML konvertiert am 01.10.2003