Postgresql – Postgres insert with on-conflict and foreign key check
Query: INSERT INTO derived (a, b, c) VALUES (?, ?, ?) ON CONFLICT (a, b, c) DO UPDATE SET a = EXCLUDED.a, b = EXCLUDED.b, c = EXCLUDED.c WHERE EXISTS (select a from primary where a = ?) Please note,…