Re: Perl DBI - How to handle large resultsets?
- From: xhoster@xxxxxxxxx
- Date: 28 Jul 2005 18:21:00 GMT
"david best" <david.best@xxxxxxxxx> wrote:
> 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.
Which line is line 115?
> The only reason I can figure is because I have a couple of queries that
> return a large resultset
How do you figure that?
>
> 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";
Is there supposed to be a die in there somewhere? A very good reason to
use RaiseError and let DBI do the dirty work for you.
> $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')");
Are you using strict? If not, then why not? If so, where is $repo_sth
being declared?
> $repo_sth->execute($snap_id) or die $DBI::errstr;
> };
> }
> # check for errors.. If there are any rollback
> if ( $@ ) {
> $err = 1;
> }
>
> $repo_sth->finish();
Are you allowed to "finish" an insert statement? I thought that was only
for selects.
> $target_sth->finish();
>
> return $err;
> }
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.
- Follow-Ups:
- Re: Perl DBI - How to handle large resultsets?
- From: stone
- Re: Perl DBI - How to handle large resultsets?
- References:
- Perl DBI - How to handle large resultsets?
- From: david best
- Perl DBI - How to handle large resultsets?
- Prev by Date: Re: multidimensional insertion order
- Next by Date: Re: multidimensional insertion order
- Previous by thread: Perl DBI - How to handle large resultsets?
- Next by thread: Re: Perl DBI - How to handle large resultsets?
- Index(es):
Relevant Pages
|
|