Re: currval() within one statement

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: currval() within one statement
Дата
Msg-id 4795B3D4.5020201@archonet.com
обсуждение исходный текст
Ответ на Re: currval() within one statement  (sad <sad@bankir.ru>)
Ответы Re: currval() within one statement  (sad <sad@bankir.ru>)
Список pgsql-sql
sad wrote:
> A. Kretschmer wrote:
> 
>>> is it expected that the currval() changes its value between calls 
>>> within one statement ?
> 
>> Conclusion, don't call nextval() within a TRIGGER, and insert either
>> nextval() for the column or omit this column.
> 
> I only note that i still want to discuss the titled problem or to be
> given an exact pointer to documentation regarding the currval() behavior
> in the described situation, that i had.

Well, the page in the docs isn't hard to find - http://www.postgresql.org/docs/8.2/static/functions-sequence.html

But surely it works exactly as you would expect it to.

nextval(S) advances the sequence and returns the new value

currval(S) returns the current value of sequence S, which is whatever 
the previous call to nextval(S) returned. In the even you haven't called  nextval(S) then it is undefined.


What do you think should happen?

--   Richard Huxton  Archonet Ltd


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

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: currval() within one statement
Следующее
От: sad
Дата:
Сообщение: Re: currval() within one statement