A Database Example
my $attr = { AutoCommit => 0 }; my $dsn = 'dbi:Pg:dbname=products'; sub get_categories_by_mgr { my($prod_mgr_id) = @_; my $dbh = DBI->connect($dsn, $user, $pswd, $attr) or die $DBI::errstr; my $sql = 'SELECT * FROM prod_category WHERE prod_mgr_id = ?'; my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute($prod_mgr_id) or die $dbh->errstr; my @categories; while(my $row = $sth->fetchrow_arrayref) { push @categories, $row; } die $sth->errstr if $sth->err; $dbh->disconnect or die $dbh->errstr; return \@categories; }