On Wed, Apr 1, 2020 at 6:49 AM Heinemann, Manfred (IMS) <HeinemannM@imsweb.com> wrote:
Can something explain why something like the following could happen?
INSERT INTO task_history (task_id, user_id, task_date)
SELECT task_id, user_id, task_date
FROM task
WHERE task_id IN (1, 2, 3);
ERROR: insert or update on table "task_history" violates foreign key constraint "fk_task_history_task_id"
Detail: Key (task_id)=(1) is not present in table "task".
Would you share the DDL create table and create FK statements? Seems weird for sure, but it would help to have the DDL to diagnose. Also, if you can provide sample data that generates this error, that will help everyone interested to reproduce your issue.