| От | Jackson, DeJuan |
|---|---|
| Тема | RE: [GENERAL] getting the currval of a sequence |
| Дата | |
| Msg-id | F10BB1FAF801D111829B0060971D839F399542@cpsmail обсуждение |
| Список | pgsql-general |
> > I think you should just go with what Vadim suggested and use:
> > select currval('my_sequence');
> > This will be the same within a transaction, even if there is another
> > transaction using the same sequence.
>
> Sorry, I wasn't thinking of it happening in the same transaction. In
> that
> case that would be the thing to do. If on the other hand you needed
> that
> number over multiple transactions, wouldn't what I had suggested work?
>
> ...james
>
Yes it would, but your suggestion introduces problems of it's own. The
whole point of a transaction is encapsulate a logical unit of work, such
that it all succeeds together or it all fails together. This would
include the incrementing of the sequence. The way that you are
suggestion you would always increment the sequence even if you never
used it, it just seems like a waste to me.
-DEJ
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера