postgresql duplicate key violates unique constraint

Robby Russell wrote in post #72333:

SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);

reload your app...and see if its still happening.

Good luck!

-Robby

I don't code with Ruby but i registered only to say THANK YOU Robby you saved my day.

toni t. wrote in post #1102290:

Robby Russell wrote in post #72333:

SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);

reload your app...and see if its still happening.

Good luck!

-Robby

I don't code with Ruby but i registered only to say THANK YOU Robby you saved my day.

Hi,

I am writing below statement in pqsl file in function endpoint_to_dyninfo_func()

SELECT setval('endpoints_dyninfo_id_seq', (SELECT MAX(id) FROM endpoints_dyninfo));

But i am gettign error if i am compiling using user msw as, psql -Umsw < all_trigger_func.pgsql

ERROR: syntax error at or near "endpoints_dyninfo_id_seq" LINE 22: SELECT setval('endpoints_dyninfo_id_seq', (SELECT MAX(...                               ^ ERROR: function endpoint_to_dyninfo_func() does not exist

Same statement i can use using below steps. 1> Ratnesh-alt:/databases/databases/pg_log # psql -Umsw 2> msw=# SELECT setval('endpoints_dyninfo_id_seq', (SELECT MAX(id) FROM endpoints_dyninfo)); setval