MedanKia - Han Lin [EMAIL PROTECTED] wrote:
> Hi guys,
> 
> I have a problem with DBD-Pg when try to talk to Postgresql. I always get
> this error :
> 
> Undefined subroutine &Pg::connectdb called at test.pl line 4.

If DBD::Pg is really what you have, then do

  perldoc DBD::Pg

at a command prompt to find out how to properly connect to a
Postgresql database using DBD::Pg.

Here's what DBD::Pg version 1.21 says in the perldocs

  $dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "");

> 
> Below is my code ?
> 
> 1.#!/usr/bin/perl -w
> 2.
> 3.use Pg;
> 4.    $conn = Pg::connectdb("dbname=template1");

Here's what DBD::Pg version 1.21 says in the perldocs

        $dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "");

That is very different from what you have above.

HTH.

-- 
Hardy Merrill
Red Hat, Inc.

> 5.    $res  = $conn->exec("SELECT * from pg_user");
> 6.    while (@row = $res->fetchrow) {
> 7.        print = join(" ", @row);
> 8.    }
> 
> I tried to uninstall and reinstall with any older version and latest version
> of DBD-Pg, but nothing help. Which version should I install?
> 
> For those who has these experience before, please advise.
> 
> Regards,
> Han Lin

Reply via email to