#!/usr/bin/perl -w
use strict;
use DBI;
my $dbname = "jonas"; my $user = "jonas"; my $passwd = "jonas";
my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $user, $passwd);

print "SQL> ";
while( my $stmt = <STDIN> )
  {
    my $sth = $dbh->prepare($stmt);
    $sth->execute; 
    if( $stmt =~ /^select/i ) {
      while (my $ary_ref = $sth->fetch) {
	foreach my $col ( @$ary_ref ) { print " | $col \t" if $col }
	print "\n";
      }
    }
    $sth->finish;
    print "SQL> ";
  }
$dbh->disconnect;


