Re: Performing FETCH ALL from a SCROLL CURSOR failing to return results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eliot Gable <egable+pgsql-general(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Performing FETCH ALL from a SCROLL CURSOR failing to return results
Date: 2010-03-25 21:43:50
Message-ID: 24903.1269553430@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Eliot Gable <egable+pgsql-general(at)gmail(dot)com> writes:
> Inside my PL/PGSQL stored procedure, I am opening the cursor like so:

> OPEN source_host;
> FETCH source_host INTO src_host;

So you already fetched the one row in the cursor. FETCH ALL really
means "fetch all the rest of the rows", which is why it returns nothing.
The other variants you mention will reposition the cursor so they can
re-read the row.

> I absolutely need to have FETCH ALL working.

It is working. What you're not doing correctly is repositioning the
cursor to before the first row. Try MOVE BACKWARDS ALL.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2010-03-25 22:22:54 Re: Get the list of permissions/privileges on schema
Previous Message David Fetter 2010-03-25 21:17:31 Re: [GENERAL] question (or feature-request): over ( partition by ... order by LIMIT N)