0

I'm trying to insert records but where a match already exists, it should update but i keep getting the error below.

ERROR: ON CONFLICT DO UPDATE not supported with exclusion constraints

Below is my update query

INSERT INTO table_b (b)
SELECT  array_remove(ARRAY[(SELECT id FROM table_c c WHERE c.id_a=u.id_a AND c.type_id=1),
(SELECT id FROM table_c c WHERE c.id_a=u.id_b AND c.type_id=2)],NULL)
FROM table_a u 
ON CONFLICT ON CONSTRAINT b_constr 
DO UPDATE SET b =  EXCLUDED.b;

below is also a constraint on table_b

CREATE TABLE table_b
(
  id ,
  b integer[],
  CONSTRAINT b_constr EXCLUDE 
  USING gist (b WITH &&)
)

How do I get to update the rows where a match already exists

olan24
  • 27
  • 6
  • Does this answer your question? [How to use ON CONFLICT with Exclusion Constraint?](https://stackoverflow.com/questions/55919404/how-to-use-on-conflict-with-exclusion-constraint) – Oleksii Tambovtsev Jan 21 '22 at 21:32
  • not really cause i need the update to be done. is there another way I can achieve that? – olan24 Jan 21 '22 at 21:40

0 Answers0