| От | Greg Stark |
|---|---|
| Тема | Re: most idiomatic way to "update or insert"? |
| Дата | |
| Msg-id | 871xili91z.fsf@stark.xeocode.com обсуждение исходный текст |
| Ответ на | Re: most idiomatic way to "update or insert"? (Matteo Beccati <php@beccati.com>) |
| Список | pgsql-general |
Matteo Beccati <php@beccati.com> writes: > I added the error check with a second UPDATE try after INSERT to increase > accuracy. In fact, INSERTs were sometimes failing because of concurrency, and > this was the only viable solution I found to avoid losing data. in the general case you could have someone else delete the record again before you get the chance to update it again. to handle this case you would actually have to make it a loop. this is the main reason a built-in merge command could be nice, it would avoid the need to loop, since it can take the lock on the existing record if it's there or perform the insert if not. -- greg
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера