A Database Example
- Now that we have exception handling in place
my $attr = { AutoCommit => 0, RaiseError => 1, PrintError => 0 }; my $dsn = 'dbi:Pg:dbname=products'; sub get_categories_by_mgr { my($prod_mgr_id) = @_; my $dbh = DBI->connect($dsn, $user, $pswd, $attr); my $sql = 'SELECT * FROM prod_category WHERE prod_mgr_id = ?'; my $result = $dbh->selectall_arrayref($sql, {}, $prod_mgr_id); $dbh->disconnect; return $result; }