#!/usr/bin/perl use Pg; print "Content-type: text/html\n\n"; print "<html>\n<body>\n"; $con = Pg::connectdb("user=username password=yourpassword dbname=databasename"); if ($con->status != PGRES_CONNECTION_OK) { print "connect failed"; # exit; } $res = $con->exec("insert into tbl1 (tim,memo) values('now','by perl')"); if($res->resultStatus != PGRES_COMMAND_OK) { print "command failed"; # exit; } $res = $con->exec("select id,tim,memo from tbl1 order by id"); if($res->resultStatus != PGRES_TUPLES_OK) { print "select failed"; # exit; } $N = $res->ntuples; for ($i=0;$i<$N;$i++) { print $res->getvalue($i,0); print "&nbsp;"; print $res->getvalue($i,1); print "&nbsp;"; print $res->getvalue($i,2); print "<br>\n"; } print "</body>\n</html>\n";