| От | 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
|
| Список | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера