#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
my ($dbh, $sth);
$dbh = DBI->connect ("DBI:mysql:host=192.168.0.1;database=myDB",
"user", "pw", {PrintError => 0, RaiseError => 1});
&fetch_ent();
$dbh->disconnect();
exit(0);
sub fetch_ent {
my $sth = $dbh->prepare (" SELECT Firma, Strasse, PLZ, Ort, EID
FROM firma
WHERE Firma LIKE 'N%'
");
$sth->execute();
while (my ($firma, $strasse, $plz, $ort, $eid) = $sth->fetchrow_array()) {
print "
\n",
"",
"$firma | $strasse | $plz | $ort | ",
" ",
" |
\n",
"\n";
&fetch_contact($eid);
print " |
\n";
}
$sth->finish();
}
sub fetch_contact {
my $eid = shift @_;
my $sth = $dbh->prepare (" SELECT Name, Vorname
FROM person
WHERE EID = '$eid'
");
$sth->execute();
while (my ($nachname, $vorname) = $sth->fetchrow_array()) {
print "",
"$nachname | $vorname | ",
"
";
}
$sth->finish();
}