Re: Cursors and recursion

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Cursors and recursion
Дата
Msg-id 20051228170357.GA29290@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Cursors and recursion  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
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-ITERATING

-- 
Michael Fuhr


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jaime Casanova
Дата:
Сообщение: Re: instead of trigger in pg
Следующее
От: Don Croata
Дата:
Сообщение: Re: Cursors and recursion