Re: going crazy with serial type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: going crazy with serial type
Дата
Msg-id 5327.1012511478@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: going crazy with serial type  (Cindy <ctmoore@uci.edu>)
Список pgsql-general
Cindy <ctmoore@uci.edu> writes:
> OK, next question.  I'm trying to use nextval/currval and I'm getting
> this:
> search_info=# select currval('state_vectors_id_seq');
> ERROR:  state_vectors_id_seq.currval is not yet defined in this session

currval is defined to return the value most recently returned by nextval
in the current session.  Thus, without a prior nextval, you get an error.
The reason for this is to make it useful in a situation where multiple
clients are concurrently obtaining values from the same sequence.

The 7.2 documentation set has been improved (or at least I'd like to
think so) over 7.1's description of sequence stuff.  You may find that
reading

http://developer.postgresql.org/docs/postgres/datatype.html#DATATYPE-SERIAL
http://developer.postgresql.org/docs/postgres/functions-sequence.html
http://developer.postgresql.org/docs/postgres/sql-createsequence.html

reduces your level of confusion.  (Or not, but at least we tried...)
Note that 7.1 does not have the int8-based sequences described there,
but other than that I believe all the info carries back to 7.1.

            regards, tom lane

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

Предыдущее
От: Fran Fabrizio
Дата:
Сообщение: Re: going crazy with serial type
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: Function to Pivot data