Re: Cursors and recursion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Don Croata <el(dot)croata(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Cursors and recursion
Date: 2005-12-28 15:48:25
Message-ID: 17343.1135784905@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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 Jaime Casanova 2005-12-28 16:03:32 Re: instead of trigger in pg
Previous Message Greg Stark 2005-12-28 15:47:33 Re: "large" IN/NOT IN subqueries result in query returning wrong data