| От | Bryan White |
|---|---|
| Тема | Re: Errors attempting to insert duplicate values |
| Дата | |
| Msg-id | 008101bfd21c$47fc5660$2dd260d1@arcamax.com обсуждение исходный текст |
| Ответ на | Errors attempting to insert duplicate values ("Bryan White" <bryan@arcamax.com>) |
| Список | pgsql-general |
> Bryan White wrote: > > > > I have a table with a unique index. When I go to insert a new value into > > the table my code does not know if the record is already there. To me there > > are two choices: > > > > 1) Do a select for the record and insert only if not found. > > > > 2) Do a blind insert and relay on the unique index to fail the insert if > > there is a duplicate. > > 3) Use a sequence to generate unique indicies for you? Sorry but I was not clear. I need to insert a record only if it does not exist. If it does exists then I do nothing. However I do need to know if it was inserted. Its seems most efficient to just attempt the insert and look at the result. My only complaint is the log file is littered the error messages about attempting to insert a duplicate.
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера