Re: GETTING INFO FROM SEQUENCE OBJECTS

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: GETTING INFO FROM SEQUENCE OBJECTS
Дата
Msg-id 20091103062240.GA9363@a-kretschmer.de
обсуждение исходный текст
Ответ на GETTING INFO FROM SEQUENCE OBJECTS  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Ответы corrupt db  (Lars Gustafsson <gumse@mac.com>)
Список pgsql-novice
In response to JORGE MALDONADO :
> How do I use the functions to get data from sequence objects?
> For example, I need to know what is the value of a serial field after inserting
> a new record; the one assigned to the record just inserted.
>  
> I have tried the psql interfase with the following:
> select currval('restaurant.ordenes_clave_seq');
> but I get a message telling me that "currval of sequence "ordenes_clave_seq" is
> not yet defined in this session.

You have to use nextval() first, without nextval() the current value of
the sequence are undefined in this session.

In other words: first insert your new row into the table, after that
call currval().


Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

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

Предыдущее
От: Brian Modra
Дата:
Сообщение: Re: GETTING INFO FROM SEQUENCE OBJECTS
Следующее
От: Richard Broersma
Дата:
Сообщение: Bug - DatabaseMetaData.getCatalogs() was [Novice] Can't get list of databases with \list