D
david best
Hey all,
I'm getting the errors:
DBD:g::st fetchrow_array failed: no statement executing at ./snap.pl
line 115.
DBD:g::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;
}
I'm getting the errors:
DBD:g::st fetchrow_array failed: no statement executing at ./snap.pl
line 115.
DBD:g::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;
}