Re: Sequences
От | Markus Bertheau |
---|---|
Тема | Re: Sequences |
Дата | |
Msg-id | 1013437356.3653.28.camel@entwicklung01.cenes.de обсуждение исходный текст |
Ответ на | Sequences ("Hunter, Ray" <rhunter@enterasys.com>) |
Список | pgsql-sql |
On Mon, 2002-02-11 at 14:43, Hunter, Ray wrote: > I have various sequences in my database set up for ids. My question is: > How can I get the current value of the sequence without creating a session > and using the currval function? > > I would like to take the current value of the sequence and use it for a > value in an insert statement. > > > Example: > > insert into users ( "user_id", "user_fname", "user_lname", > "user_email" ) > values ( 'current sequence', 'Ray', 'Hunter', > 'rhunter@enterasys.com' ); > You probably wouldn't want to use the current but the next value of the sequence. Common solution is to set the default for the column user_id to something like nextval(users_user_id_seq"::text) and omit user_id in the insert statement such that the default value is taken. Markus Bertheau Cenes Data GmbH
В списке pgsql-sql по дате отправления: