Re: SQL-question: returning the id of an insert querry

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: SQL-question: returning the id of an insert querry
Дата
Msg-id 87he1dz8tj.fsf@asmodeus.mcnaught.org
обсуждение исходный текст
Ответ на SQL-question: returning the id of an insert querry  (Andreas Fromm <Andreas.Fromm@physik.uni-erlangen.de>)
Список pgsql-general
Scott Chapman <scott_list@mischko.com> writes:

> On Sunday 09 November 2003 03:13, Martijn van Oosterhout wrote:
> > After you've done the insert on the address table, you can use
> > currval('address_id_seq') (or equivalent) to get the ID. Ofcourse you
> > have to have used nextval() for the original insert.
>
> What if someone else inserts another address before I get the currval?
> I'm out of luck then, right?

No, currval() handles that--see the docs.

-Doug

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

Предыдущее
От: Scott Chapman
Дата:
Сообщение: Re: SQL-question: returning the id of an insert querry
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: SQL-question: returning the id of an insert querry