Re: proposal - plpgsql - FOR over unbound cursor

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: proposal - plpgsql - FOR over unbound cursor
Дата
Msg-id 690044.1593626765@sss.pgh.pa.us
обсуждение исходный текст
Ответ на proposal - plpgsql - FOR over unbound cursor  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: proposal - plpgsql - FOR over unbound cursor  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> Last week I played with dbms_sql extension and some patterns of usage
> cursor in PL/SQL and PL/pgSQL. I found fact, so iteration over cursor (FOR
> statement) doesn't support unbound cursors. I think so this limit is not
> necessary.

I guess I don't understand why we should add this.  What does it do
that can't be done better with a plain FOR-over-SELECT?

The example you give of splitting an iteration into two loops doesn't
inspire me to think it's useful; it looks more like encouraging awful
programming practice.

> This statement can open portal for bound cursor or can iterate
> over before opened portal. When portal was opened inside FOR statement,
> then it is closed inside this statement.

And this definition seems quite inconsistent and error-prone.
The point of a FOR loop, IMO, is to have a fairly self-contained
definition of the set of iterations that will occur.  This
eliminates that property, leaving you with something no cleaner
than a hand-built loop around a FETCH command.

            regards, tom lane



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode
Следующее
От: Vik Fearing
Дата:
Сообщение: Re: SQL-standard function body