Re: ADD FOREIGN KEY fails, but the records exist

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ADD FOREIGN KEY fails, but the records exist
Date: 2021-02-15 16:27:15
Message-ID: 22cd11dc-b6de-9056-fbed-1c53065fd1e0@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/15/21 8:23 AM, Ron wrote:
> On 2/15/21 10:17 AM, Adrian Klaver wrote:
>> On 2/15/21 8:12 AM, Ron wrote:
>>> Postgresql 12.5
>>>

>> The error:
>>
>> DETAIL:  Key (amended_response_id, part_date)=(103309154, 2021-01-06
>> 00:00:00) is not present in table "employer_response"
>>
>> is pointing at 103309154 for amended_response_id =
>> employer_response_id. You are showing an employer_response_id of
>> 103309156
>
> But my query's WHERE clause specifies "amended_response_id =
> 103309154;"  (I've highlighted it, if you have a GUI MUA.)

Yes but amended_response_id is referencing employer_response_id. So do
you have a record that matches:

employer_response_id part_date

103309154 2021-01-06 00:00:00

>
>>
>>>
>>>
>>> sides=> select employer_response_id, part_date
>>> from strans.employer_response_p2021_01
>>> where *amended_response_id = 103309154; *
>>> employer_response_id |      part_date
>>> ----------------------+---------------------
>>>              103309156 | 2021-01-06 00:00:00
>>> (1 row)
>>>
>>>
>>
>>
>
> --
> Angular momentum makes the world go 'round.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-02-15 16:27:49 Re: prepare in a do loop
Previous Message Ron 2021-02-15 16:23:29 Re: ADD FOREIGN KEY fails, but the records exist