Re: Looping through cursor row batches - Mailing list pgsql-general

From Tom Lane
Subject Re: Looping through cursor row batches
Date
Msg-id 18629.1223295969@sss.pgh.pa.us
Whole thread Raw
In response to Looping through cursor row batches  ("Henry Combrinck" <henry@zen.co.za>)
List pgsql-general
"Henry Combrinck" <henry@zen.co.za> writes:
> Anyone know the most efficient way of FETCHing a batch of rows, and
> looping through them in a function?  FETCHing a record at a time will
> work, but I was wondering whether this could be done.

You're outsmarting yourself.  plpgsql already does the equivalent of
this under the hood, there is no need for you to try to make it happen
at user level.  Just use a plain ol' FOR rec IN SELECT and forget the
explicit cursor.

            regards, tom lane

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: restore a dump db from tar file
Next
From: "Alain Roger"
Date:
Subject: Re: restore a dump db from tar file