Re: [GENERAL] Fun with Cursors- how to rewind a cursor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Postgres User" <postgres(dot)developer(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Fun with Cursors- how to rewind a cursor
Date: 2007-03-02 07:06:49
Message-ID: 2689.1172819209@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

"Postgres User" <postgres(dot)developer(at)gmail(dot)com> writes:
> On 3/1/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> "Postgres User" <postgres(dot)developer(at)gmail(dot)com> writes:
>>> <before opening cursor> ref_entry = 'c_entry';
>>> <after looping thru cursor> MOVE Backward All In c_entry;
>>
>> You have to use EXECUTE for the latter.

> I had tried several variations of MOVE Backward inside an Execute
> statement earlier. And now, I'm seeing this error appear again:
> ERROR: 0A000: cannot manipulate cursors directly in PL/pgSQL

Hm, you're right. This arises from the fact that _SPI_execute_plan
rejects cursor-related utility statements. While I'd never stopped
to question that before, it does seem like this restriction is a
bit pointless. Does anyone remember why it's like that?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-03-02 07:53:45 Re: Differences in identical queries
Previous Message Tom Lane 2007-03-02 06:26:37 Re: How often do I need to reindex tables?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2007-03-02 07:11:42 Re: HOT - preliminary results
Previous Message Pavan Deolasee 2007-03-02 07:01:00 Re: HOT - preliminary results