From: Michael Fuhr <mike@fuhr.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Don Croata <el.croata@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Cursors and recursion
Date: Wed, 28 Dec 2005 10:03:57 -0700
Message-ID: <20051228170357.GA29290@winnie.fuhr.org> (raw)
In-Reply-To: <17343.1135784905@sss.pgh.pa.us>
References: <be9533860512280629m1c1163bm73fef37f17541423@mail.gmail.com>
<17343.1135784905@sss.pgh.pa.us>
On Wed, Dec 28, 2005 at 10:48:25AM -0500, Tom Lane wrote:
> Don Croata <el.croata@gmail.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.
Or, if possible, use "FOR record_or_row IN query LOOP" instead of
an explicit cursor.
http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERA...
--
Michael Fuhr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, tgl@sss.pgh.pa.us, el.croata@gmail.com
Subject: Re: Cursors and recursion
In-Reply-To: <20051228170357.GA29290@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox