Perl DBI and postgres - Mailing list pgsql-general

From david.best@sympatico.ca
Subject Perl DBI and postgres
Date
Msg-id 53350.205.210.232.62.1122559523.squirrel@www.cakeorations.ca
Whole thread Raw
List pgsql-general
This is probably just a general DBI question but I get the following
errors when I run my code:

DBD::Pg::st fetchrow_array failed: no statement executing at ./snap.pl
line 110.
DBD::Pg::st fetchrow_array failed: no statement executing at ./snap.pl
line 110.

Line 110 is a disconnect statement:

$target_dbh->disconnect();

I have multiple functions which access a target database, take the
information and put it back into a repository.   They all follow this
format, the database handlers are passed in, statement handlers are
created and closed at the end of the function.

sub free_space {

 my $err=0;
 my ($repo_dbh, $target_dbh, $snap_id) = @_;
 my $target_sth = $target_dbh->prepare(
               q{ SELECT columns
                  FROM the table }) or "Can't prepare statement:
$DBI::errstr";
 $target_sth->execute() or die $DBI::errstr;

  while (my ($data) = $target_sth->fetchrow_array()) {
   eval {
    $repo_sth = $repo_dbh->prepare("INSERT into thetable
                                      (columns)
                                   VALUES (?, '$data')");
    $repo_sth->execute($snap_id) or die $DBI::errstr;
   };
  }
   # check for errors.. If there are any rollback
   if ( $@ ) {
      $err = 1;
   }

 $repo_sth->finish();
 $target_sth->finish();

 return $err;
}

The main function just opens connections to the repository and target
database and closes them at the end with disconnects and that is where the
error is occuring.

Any ideas?


pgsql-general by date:

Previous
From: germ germ
Date:
Subject: Re: problem inserting with sequence
Next
From: Jaime Casanova
Date:
Subject: Re: Trigger ad mutli database