Operating on Postgresql databases in perl 
See:
http://structbio.vanderbilt.edu/chazin/wisdom/dbi_howto.html
To execute a basic SQL statement:
There are three steps to executing a basic SQL statement:
This example is a statement that will retrieve the rows in a table called reference.
$sth = $dbh->prepare( "
SELECT reference.ref_num, type, reference.title, pub_year, summary
FROM reference
");
if ( !defined $sth ) {
die "Cannot prepare statement: $DBI::errstrn";
}
This is done using the following line:
- Fetch the rows into an array or variables:
This is an example that fetches the attributes from the rows into variables:
while ( ($ref_num, $type, $title, $pub_year, $summary ) = $sth->fetchrow()){
...intervening code…
}
This is an example that fetches the attributes into an array:
while ( @row = $sth->fetchrow()){
...intervening code…
}
After you are finished with the SQL statement, you should release the statement handle as follows: