#!/usr/bin/perl print "Test of S.u.S.E. Linux 5.3 PostgreSQL access(DBI)\n"; use DBI; $dbh = DBI->connect("dbi:Pg:dbname=mypsqldb;host=localhost;port=5432","postgres",""); $sql = "select * from mypsqltable"; $sth = $dbh->prepare($sql); $sth->execute(); $rownum = $sth->rows; # number of rows $colnum = $sth->{NUM_OF_FIELDS}; # number of columns # display column name for ($i = 0; $i < $colnum; $i++){ print " $sth->{NAME}->[$i]"; } print "\n"; # display column value while (@row_ary = $sth->fetchrow_array){ for ($i = 0; $i < $colnum; $i++){ print " $row_ary[$i]"; } print "\n"; } $sth->finish; $dbh->disconnect;