Re: SERIAL behaviour
| От | Steve Brett |
|---|---|
| Тема | Re: SERIAL behaviour |
| Дата | |
| Msg-id | C05E7DA1218ED411BF8A00105AC95A8E05B71AEB@sv-cntrmail.emis.local обсуждение исходный текст |
| Ответ на | SERIAL behaviour (Eugene <foo@bar.com>) |
| Список | pgsql-general |
you can use currval() to get the current value of a sequence.
however if your key value is set to serial and it's default is the nextval
then don't reference it in your insert i.e.
insert into foo(forename,surname) values ('Steve','Brett');
where the key for foo is an id of type serial.
currval() 'should' be safe for use within transactions.
Steve
> -----Original Message-----
> From: Adrian 'Dagurashibanipal' von Bidder
> [mailto:avbidder@fortytwo.ch]
> Sent: 15 July 2002 14:47
> To: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] SERIAL behaviour
>
>
> On Sun, 2002-07-14 at 03:59, Eugene wrote:
> [ SERIAL type / SEQUENCEs and transactions ]
>
> Closely related: what's the official/preferred way if I'm
> inserting rows
> into a table with a auto assigned id (SERIAL), to get the
> newly created
> id? asking the sequence obviously will not work - as the sequence will
> advance when the next value is inserted from another transaction.
>
> cheers
> -- vbi
>
> --
> secure email with gpg http://fortytwo.ch/gpg
>
В списке pgsql-general по дате отправления: