Re: FK constraint question

From: Steve Midgley <science(at)misuse(dot)org>
To: "Heinemann, Manfred (IMS)" <HeinemannM(at)imsweb(dot)com>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: FK constraint question
Date: 2020-04-01 15:29:44
Message-ID: CAJexoSJJ3GQ1y_CaRU+5dZ7TOa3umfsN6Kt-70WyiAbjns921A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Apr 1, 2020 at 6:49 AM Heinemann, Manfred (IMS) <
HeinemannM(at)imsweb(dot)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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ruwan Fernando 2020-04-05 08:22:03 How do CHECK Constraint Function privileges work?
Previous Message Heinemann, Manfred (IMS) 2020-04-01 13:49:03 FK constraint question