Skip to content
Advertisement

PostgreSQL duplicate key value violates unique constraint while using on conflict do nothing on insert

Table def:

I have a function that inserts new rows into the database:

It fails with

the index

Although running the relevant insert on its own with duplicate values it has no problem with it.

I can’t understand what seems to be the the difference between the function and the single statement?

This also works without a problem:

same error with

I am using Postgresql 12.3

Advertisement

Answer

Seems like I had 2 such functions trigerring on the same logic which caused the problem. Thank you all for help.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement