Perl DBI - How to handle large resultsets?
- From: "david best" <david.best@xxxxxxxxx>
- Date: 28 Jul 2005 11:09:25 -0700
Hey all,
I'm getting the errors:
DBD::Pg::st fetchrow_array failed: no statement executing at ./snap.pl
line 115.
DBD::Pg::st fetchrow_array failed: no statement executing at ./snap.pl
line 115.
The only reason I can figure is because I have a couple of queries that
return a large resultset... How do I handle such cases? Here is same
code:
The database handlers get passed in. Don't worry about the parameters
to the queries because I edited that out.
sub myproc {
my $err=0;
my ($repo_dbh, $target_dbh, $snap_id) = @_;
my $target_sth = $target_dbh->prepare(
q{ SELECT columns
FROM dba_free_space }) 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 mytable
(snap, data)
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;
}
.
- Follow-Ups:
- Re: Perl DBI - How to handle large resultsets?
- From: Keith Keller
- Re: Perl DBI - How to handle large resultsets?
- From: xhoster
- Re: Perl DBI - How to handle large resultsets?
- Prev by Date: Re: can't run perl commands from command line
- Next by Date: Re: multidimensional insertion order
- Previous by thread: FAQ 1.7 How stable is Perl?
- Next by thread: Re: Perl DBI - How to handle large resultsets?
- Index(es):
Relevant Pages
|