Postgres 9.6: Insert into view with on conflict

Viewed 137

I have 2 tables both with unique constraints, 1 view that joins those 2 tables and an INSTEAD OF INSERT trigger that allows INSERT or UPDATE on the view.

Everything works perfectly for regular INSERT or UPDATE but if I do INSERT .. ON CONFLICT(tableAColumn,tableBColumn) DO UPDATE then I get the error:

[42P10] ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification

If the view was automatically updatable then I think I could just use a WITH CHECK OPTION but how do I do that with a INSTEAD OF INSERT trigger?

Or another way to ask how do I make the view have the same constraints as the tables it is built from?

0 Answers
Related