Re: Getting "duplicate key value violates unique constraint" on 2nd run of function.

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Getting "duplicate key value violates unique constraint" on 2nd run of function.
Дата
Msg-id dcc563d10911251549g6e659ee2idd7feca917a7177b@mail.gmail.com
обсуждение исходный текст
Ответ на Getting "duplicate key value violates unique constraint" on 2nd run of function.  (David Kerr <dmk@mr-paradox.net>)
Ответы Re: Getting "duplicate key value violates unique constraint" on 2nd run of function.  (David Kerr <dmk@mr-paradox.net>)
Список pgsql-general
On Wed, Nov 25, 2009 at 3:19 PM, David Kerr <dmk@mr-paradox.net> wrote:
> Howdy all.
>
> I've got a function that basically does this:
>
> DELETE FROM test where id = $1
> INSERT into test (id) values ($1);

You're missing a semi-colon up there, is that a problem?

> id is the primay key, so it has to be unique.
>
> First time I run it, works great.
> If I run it again in the same session, I get
> ERROR:  duplicate key value violates unique constraint "test_pkey"
>
> If I log out and then log back in, it runs fine again (the first time).
>
> Is there some setting for the function that I need to set to make this run correctly
> every time?

This should just work.  Please post a more complete example of what's
happening (php code, queries something) that reproduces this problem
in a way I can just type it in and see it on my end.

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

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: pg_standby instructions
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Postgres database performance on 6 core Opteron vs 4 core Xeon