for ( my $i = 1 ; $i <= @spalte ; $i++ ) # Nochmal alle Spalten durchgehen { if ( $spkey[$i] != 0 && $sref->[$i] ne "" ) # Wenn Primärschlüssel { if ( $sptyp[$i] eq "N" ) # Wenn numerisch... { $sql .= $spalte[$i] . "=" . $sref->[$i] . " and "; } # dann anhängen "= and " else # ansonsten { $sql .= $spalte[$i] . "='" . $sref->[$i] . "' and "; } # anhängen "='' and " } $sql =~ s/ and $// ; # Am Ende ist hinten ein " and " zu viel - das wird gelöscht print $sql. "\n"; my $sth = $dbh->prepare($sql) || die "$DBI::errstr\n"; # SQL-Statement vorbereiten... $sth->execute() || die "$DBI::errstr\n"; # ... und ausführen }