| От | Tom Lane |
|---|---|
| Тема | Re: Last inserted id |
| Дата | |
| Msg-id | 14006.1005578992@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Last inserted id (David Horwitz <Dhorwitz@ched.uct.ac.za>) |
| Список | pgsql-odbc |
David Horwitz <Dhorwitz@ched.uct.ac.za> writes:
> Actually the issue is b) is multi-user safe
> *if* you have an exclusive lock on the table. If you don't it is quite
> possible for a user to insert an other record between your insertion and the
> currval() call
False. Option B is multi-user safe, period. The reason is that currval
returns the value last obtained by nextval *in your own session*,
independently of what anyone else has done meanwhile.
I tend to prefer option A (select nextval and insert) myself, just
because it seems more intuitive. But if that's not convenient for
some reason, option B works fine too.
regards, tom lane
В списке pgsql-odbc по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера