Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Howdy all.

I've got a function that basically does this:

DELETE FROM test where id = $1
INSERT into test (id) values ($1);

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?

Thanks

Dave

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux