From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ron <ronljohnsonjr@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: ADD FOREIGN KEY fails, but the records exist
Date: Mon, 15 Feb 2021 09:03:56 -0800
Message-ID: <27b05961-ead0-a75e-d90d-18ff8ea8259f@aklaver.com> (raw)
In-Reply-To: <ae30118a-c64c-9351-5745-38b9a4fbd135@gmail.com>
References: <e8a458ad-2f92-6f8d-c485-8f72e3d4f72a@gmail.com>
<37d7ad6b-3da6-0778-47fe-e6256babb4ad@aklaver.com>
<d67297d5-a0f2-d876-ec23-5b1c6f418bf8@gmail.com>
<22cd11dc-b6de-9056-fbed-1c53065fd1e0@aklaver.com>
<ae30118a-c64c-9351-5745-38b9a4fbd135@gmail.com>
On 2/15/21 8:55 AM, Ron wrote:
>
>
> The time portions of the part_date fields don't match...
>
> sides=> ALTER TABLE employer_response
> ADD CONSTRAINT amended_response_fk FOREIGN KEY
> (amended_response_id, part_date)
> REFERENCES employer_response(employer_response_id, part_date)
> ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED ;
> ERROR: insert or update on table "employer_response_p2021_01" violates
> foreign key constraint "amended_response_fk"
> DETAIL: Key (amended_response_id, part_date)=(103309154, 2021-01-06
> 00:00:00) is not present in table "employer_response".
> sides=>
>
> sides=> select employer_response_id, amended_response_id, part_date
> from strans.employer_response
> where amended_response_id = 103309154;
> employer_response_id | amended_response_id | part_date
> ----------------------+---------------------+---------------------
> 103309156 | *103309154 *| 2021-01-06*00:00:00*
> (1 row)
>
> sides=>
> sides=>
> sides=> select employer_response_id, amended_response_id, part_date
> from strans.employer_response
> where employer_response_id = 103309154;
> employer_response_id | amended_response_id | part_date
> ----------------------+---------------------+---------------------
> *103309154* | | 2021-01-06 *15:14:03*
> (1 row)
To add to my previous post regarding the part about the data transfer
process. You might look for code that did something like:
select current_date::timestamp;
current_date
---------------------
2021-02-15 00:00:00
In other words turned a date into a timestamp.
>
>
> --
> Angular momentum makes the world go 'round.
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, ronljohnsonjr@gmail.com
Subject: Re: ADD FOREIGN KEY fails, but the records exist
In-Reply-To: <27b05961-ead0-a75e-d90d-18ff8ea8259f@aklaver.com>
References: <e8a458ad-2f92-6f8d-c485-8f72e3d4f72a@gmail.com> <37d7ad6b-3da6-0778-47fe-e6256babb4ad@aklaver.com> <d67297d5-a0f2-d876-ec23-5b1c6f418bf8@gmail.com> <22cd11dc-b6de-9056-fbed-1c53065fd1e0@aklaver.com> <ae30118a-c64c-9351-5745-38b9a4fbd135@gmail.com> <27b05961-ead0-a75e-d90d-18ff8ea8259f@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox