Re: BUG #3662: Seems that more than one run of a functions causes an error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #3662: Seems that more than one run of a functions causes an error
Дата
Msg-id 27859.1192060818@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #3662: Seems that more than one run of a functions causes an error  ("Robins Tharakan" <tharakan@gmail.com>)
Список pgsql-bugs
"Robins Tharakan" <tharakan@gmail.com> writes:
> BEGIN
>     CREATE TEMPORARY SEQUENCE s INCREMENT BY 1 START WITH 1;
>     FOR rec in
>         SELECT nextval('s') as rank, tt.scheme_code, tt.ret
>     ...
>     DROP SEQUENCE s;
> END;

Sorry, that's not going to work, for fundamentally the same reason that
references in this style to temp tables don't work --- the OID of the
sequence gets embedded into the nextval() call on first use of the
function.  Consider creating the temp sequence just once per session
and resetting it on subsequent uses; or use EXECUTE to process that
SELECT.  Or maybe you could dispense with the sequence altogether ---
a local-variable counter inside the function would be a vastly
lighter-weight solution anyway.

            regards, tom lane

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

Предыдущее
От: "Roberts, Jon"
Дата:
Сообщение: Re: BUG #3667: Job scheduling with Greenplum fails
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3662: Seems that more than one run of a functions causes an error