Re: getting back autonumber just inserted

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: getting back autonumber just inserted
Дата
Msg-id 1120767709.8208.188.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на Re: getting back autonumber just inserted  (Theodore Petrosky <tedpet5@yahoo.com>)
Ответы Re: getting back autonumber just inserted  (mail TechEvolution <mail@techevolution.be>)
Список pgsql-sql
On Thu, 2005-07-07 at 15:14, Theodore Petrosky wrote:
> you have to use currval inside a transaction...
> 
> begin;
> insert something that increments the counter;
> select currval('sequence_name');
> end;
> 
> using currval inside a transaction guarantees that the
> value is correct for your insert statement and has not
> changed by another insert statement.

Actually, whether you use it inside a transaction or not, as long as
it's in the same session / connection, it is guaranteed to "do the right
thing."

Test it, you'll see.


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

Предыдущее
От: Theodore Petrosky
Дата:
Сообщение: Re: getting back autonumber just inserted
Следующее
От: mail TechEvolution
Дата:
Сообщение: Re: getting back autonumber just inserted