Perl DBI - How to handle large resultsets?




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;
}

.



Relevant Pages

  • Re: Parameter Search Form
    ... The reason for the parameter was to give the users the ability to search the ... The reason for the Like '%%' is because the user may not know the entire name ... simple queries like your, creating the SP is pretty straighforward. ... For controls, particularly when they are located on a subform, building the ...
    (microsoft.public.access.adp.sqlserver)
  • Re: ODBC Update
    ... The reason that the table is returning the same data is because you are ... >>I created a DSN for the VFP free table. ... >> When I 1st queries the table, using SQL Pass thru it work correctly. ...
    (microsoft.public.fox.vfp.queries-sql)
  • Strange behaviour with assigning permissions
    ... Is there any reason why my forms and reports don't show up alphabetically in ... My tables, queries, and macros appear properly though. ...
    (microsoft.public.access.security)
  • Re: Problem counting
    ... Without an obvious reason to move from A97 I'll stick with it for now. ... > You could do this in less than 3 queries, probably in one query IF your ... > use any square brackets within the subqueries. ... >>> Post back if you need to do this all in one query statement. ...
    (microsoft.public.access.queries)
  • Re: Odd VBA Behavior
    ... Graham R Seach wrote: ... > service is not seeing oneof them for some reason. ... > Check your queries VERY CAREFULLY. ...
    (microsoft.public.access.modulesdaovba)