Re: Duplicated entries are not ignored even if a "do instead nothing" rule is added.

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Duplicated entries are not ignored even if a "do instead nothing" rule is added.
Дата
Msg-id jfoqd6$vqm$3@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Duplicated entries are not ignored even if a "do instead nothing" rule is added.  (邓尧 <torshie@gmail.com>)
Список pgsql-general
On 2012-01-09, 邓尧 <torshie@gmail.com> wrote:

> insert into ACCOUNT(HOME)
>     select "v1" as HOME
>     where not exists (select 1 from ACCOUNT where HOME =3D "v1")
>
> Surprisingly, I still got the unique constraint violation error, but much
> fewer than before ( only 3 during the last 3 days).
> Any suggestions? Could it be a bug in psycopg2 or postgresql?

No bug, that's ecpected behavior (unless you switch to serializable isolation
level)

when I need to insert if missing and need to avoid all errors I write it like
above but wrap it in a plpgsql function with an exception clause to handle the
error.

--
⚂⚃ 100% natural

В списке pgsql-general по дате отправления:

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: How to make a non-removable row in a table?
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Numerous prepared transactions?