- or download this
my $dbh = DBI->connect($DNS, {RaiseError=>1});
my $sth = $dbh->prepare(qq{SELECT product, price, quantity
...
ask_customer ($product, $price, $quantity);
}
$dbh->disconnect();
- or download this
+----------------------+ +-----------------------+
| customer | | order |
...
| P03 | 5.50 | pliers |
| P04 | 4.00 | cutter |
+-----+-------+--------+
- or download this
my @customers = (
[ 'C01', 'Joe', 'NY' ],
...
[ 'C01', 'P04', 4 ],
[ 'C01', 'P03', 1 ]
);
- or download this
SELECT cust.name AS customer, prod.name AS product,
price, qty, qty*price AS total
...
| Sue | 28.20 |
| Joe | 25.50 |
+----------+-------+
- or download this
my %orders_by_customer = (
'Frank' => [ { product => 'pliers', qty => 9 },
...
{ product => 'pliers', qty => 1 }
]
);
- or download this
my %orders_by_customer = ();
while (my $href = $sth->fetchrow_hashref()) {
...
);
push @{$orders_by_customer{$href->{'customer'}}}, \%order;
}
- or download this
my $surname = 'Jones';
my $query=
qq{SELECT name, surname FROM employees WHERE surname = $surnam
+e };
my $sth = $dbh->prepare($query);
$sth->execute();
- or download this
my $query= qq{SELECT name, surname FROM employees WHERE surname =
+? };
my $sth = $dbh->prepare($query);
$sth->execute('Jones');