From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Don Croata <el(dot)croata(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Cursors and recursion |
Date: | 2005-12-28 17:03:57 |
Message-ID: | 20051228170357.GA29290@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, Dec 28, 2005 at 10:48:25AM -0500, Tom Lane 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.
Or, if possible, use "FOR record_or_row IN query LOOP" instead of
an explicit cursor.
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Don Croata | 2005-12-28 19:37:21 | Re: Cursors and recursion |
Previous Message | Jaime Casanova | 2005-12-28 16:03:32 | Re: instead of trigger in pg |