Re: Cursors and recursion

From: Don Croata <el(dot)croata(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Cursors and recursion
Date: 2005-12-28 19:37:21
Message-ID: be9533860512281137u42cc2a16hcd2d5b703a809bdd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Please, if someone recalls a link, book, piece of code or anything with info
about this technique for PL/PgSQL (8.1), please let us know. We've been
searching into google, groups.google, http://archives.postgresql.org and
http://www.postgresql.org/docs/8.1/interactive with no results. Most of the
answers are related to unclosed cursors for the "ERROR: cursor ... already
in use" message.

Here's the sample code for this issue (i.e. error because cursor already
defined in recursive PL/PgSQL function) at: http://www.croata.cl/cur.sql

--

Thanx again,
Cro

On 12/28/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Don Croata <el(dot)croata(at)gmail(dot)com> writes:
> > It's a function who has a cursor and calls itself, but the problem
> raises
> > after the first recursion, when PgSQL complains:
>
> > ERROR: cursor "cur" already in use
>
> > Are the cursors kept globally? or cached like TEMP TABLE?
>
> Cursor names are global within a particular session.
>
> IIRC there is a syntax for opening a cursor without specifying a name,
> in which case plpgsql will pick one that's not in use. This is probably
> what you want to use.
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message George Pavlov 2005-12-28 19:57:38 DISTINCT with NULLs and INT fields
Previous Message Michael Fuhr 2005-12-28 17:03:57 Re: Cursors and recursion