|
|
sybperl-l Archive
Up Prev Next
From: sy50027 at milton dot sbi dot com (Simon Yaminian)
Subject: Re: Queries n rows at a time
Date: Jul 15 1998 3:50PM
> From owner-SYBPERL-L@listproc.net Wed Jul 15 11:37:50 1998
> >Received: from as01.us by ltcm.com (8.7.1/1.32(sec)-LK3)
> id LAA25600; Wed, 15 Jul 1998 11:20:00 -0400
> Date: Wed, 15 Jul 1998 11:20:01 -0400
> From: Ashutosh Joglekar
> Mime-Version: 1.0
> To: SybPerl Discussion List
> Subject: Re: Queries n rows at a time
> Content-Transfer-Encoding: 7bit
> X-Listprocessor-Version: 8.2.07 -- ListProc(tm) by CREN
>
> Perhaps I have misunderstood the question but isn't it enough to run the query
> through $dbh->dbcmd, dbsqlexec (not thru $dbh->sql or siblings). Then run a
> dbnextrow loop and in the loop, work with 200 rows at a time, then get the next
> 20 rows, etc.
>
> Something like :
>
> $dbh->dbcmd($query);
> $dbh->dbsqlexec;
> $dbh->dbresults;
> my ($count) = 0;
> while (($col1, $col2, $col3) = $dbh->dbnextrow)
> {
> $count++;
> # save $col1, $col2, $col3 into some structure
> if ($count == 200)
> {
> $count = 0;
> # process the batch of rows
> }
> }
>
>
Thank you for the thought.
The hangup is that when the query is put together in the dbcmd, the
dbsqlexec call does not return until the query is completed and this
may take a while. The catch is to break the dbsqlexec call for instance
into a set of "current" and "next" exec calls so we can have a break
in the processing time while also having some data to work with. Again
put all query semantics aside. The idea may seem complicated but it is
in really simple. The key is to maintain a reference point (by Sybperl)
in the submitted query.
Regards
Simon Yaminian
|