Re: Looping through cursor row batches

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Henry Combrinck" <henry(at)zen(dot)co(dot)za>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Looping through cursor row batches
Date: 2008-10-06 12:26:09
Message-ID: 18629.1223295969@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Henry Combrinck" <henry(at)zen(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alain Roger 2008-10-06 13:03:57 Re: restore a dump db from tar file
Previous Message Raymond O'Donnell 2008-10-06 12:07:01 Re: restore a dump db from tar file