Re: going crazy with serial type

Поиск
Список
Период
Сортировка
От Darren Ferguson
Тема Re: going crazy with serial type
Дата
Msg-id Pine.LNX.4.10.10201311552480.1536-100000@thread.crystalballinc.com
обсуждение исходный текст
Ответ на Re: going crazy with serial type  (Cindy <ctmoore@uci.edu>)
Ответы Re: going crazy with serial type  (Jan Wieck <janwieck@yahoo.com>)
Список pgsql-general
For some reason unknown to myself if you have not initiated a nextval in
the same psql command line before calling currval then that is the error
msg you will get.

If you do nextval then a currval after it then that error will disappear

Darren Ferguson

On Thu, 31 Jan 2002, Cindy wrote:

>
>
> 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
> search_info=# select id from state_vectors;
>  id
> ----
>   1
> (1 row)
>
>
> shouldn't the first select have returned 1?  The state_vectors_id_seq
> is the sequence created by declaring id SERIAL in the table
> state_vectors, and I've done one INSERT INTO state_vectors VALUES
> (nextval('state_vectors_id_seq'), ... ); which worked fine and is
> where the 1 comes from.  (I'm interested in finding out the value used
> for the most recent insert, and currval seemed like a pretty painless
> way of doing so.)
>
> (I'm basing this on 4.15.2 of the postgresql faq kindly supplied
> earlier.)
>
> --CIndy
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>


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

Предыдущее
От: Jason Earl
Дата:
Сообщение: Re: going crazy with serial type
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: going crazy with serial type