Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBhGn-0007ko-LY for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 17:02:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBhGm-0006kc-Io for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 17:02:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBhGm-0006kV-8g for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 17:02:44 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBhGj-0007jX-Bv for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 17:02:43 +0000 Received: by mail-oi1-x229.google.com with SMTP id g84so8431969oib.0 for ; Mon, 15 Feb 2021 09:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=FYZA9yRIbno+sMKcZY/wd2SNGrupavegrGTTjJ2s5qQ=; b=bEsfs1Ainkn5kJZiShKkHAIwTTuzvm0OQ6HOilnfBVxaGkJakUzLvGzrVKxB6tSB57 OaN/obl+Vcjir5hZ3T/mRMAVHEzldJS8nAO6lPbQHsX+d9wVXzWTNOjYvuUaaiwjZ3jB FJyHckIhZCyrziJB5Q8wvYQKe72vs5U5zWTpaAImaxEzUJMjqPTiVxh+4ErKRtC7vkOq LBiZF57FlOuSUZbqDVT42wAJD+v53DJVm1nR8obXPXPHnEhTO/uC/weQuvNjlUL7LQr6 5OKvhUVpc4CuobV1M0/Xq/usQh/m20a/eetD21SnSxvRg9muazLXuozbDzkQf4HzVFee TI5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=FYZA9yRIbno+sMKcZY/wd2SNGrupavegrGTTjJ2s5qQ=; b=MXvY0rQraNeXWpcbalskbbxUvojnKX7apaOmWibFz4lPczaDcrETukEycIO4LMF3a5 ma8X2KUsutuJbRG5dm9lWGeJaG/XDb6di1Zhl7H+1sDst8JG1RKF4Gn1eb9IahvqRXHH 3+MulTh+vsQ0m/kT0WP5NbK984uhyAh5MXWJY95RVuOI9TS/0vpbs2VfwjL0ksM9gKWj pAJiz0imRRku+g9LC4y3Wvc1FJzEJxE7jFG+TQYxfX6nXZOwzJPCUcqZgH1RGZ87P5CY KG9EpHjI2quoyGGL9eM/h+p63rddcAYrHmmnZ9/KxIGbFPrXBiHNThruZFxjrIWTqv0g hE6Q== X-Gm-Message-State: AOAM530kVZ2fpEq5cGH1gCBpJ7rqHUQfUm+z9EGyqTAcsxUlaODw/wfH nEhf0UjzCl87IJDqyyIzuzwmszb49HqWlg== X-Google-Smtp-Source: ABdhPJwohc3E9VLoLOFXQKRG42skA66PBgG+S/40pBu5iIeLF6HVwxU/I5xfJzWNlGacoVJ44LWN/Q== X-Received: by 2002:aca:1813:: with SMTP id h19mr8881884oih.102.1613408559025; Mon, 15 Feb 2021 09:02:39 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id p7sm3368575ooa.13.2021.02.15.09.02.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Feb 2021 09:02:38 -0800 (PST) Subject: Re: ADD FOREIGN KEY fails, but the records exist To: Adrian Klaver , "pgsql-generallists.postgresql.org" References: <37d7ad6b-3da6-0778-47fe-e6256babb4ad@aklaver.com> <22cd11dc-b6de-9056-fbed-1c53065fd1e0@aklaver.com> <5be653a0-cd07-11c3-2ced-e7e250547c8f@aklaver.com> From: Ron Message-ID: Date: Mon, 15 Feb 2021 11:02:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5be653a0-cd07-11c3-2ced-e7e250547c8f@aklaver.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/15/21 10:58 AM, Adrian Klaver wrote: > On 2/15/21 8:55 AM, Ron wrote: >> >> >> On 2/15/21 10:27 AM, Adrian Klaver wrote: >>> 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 >> >> 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) >> > > Well since it is the same column(type) then it had to be something in the > transfer of the data from Oracle to Postgres. What are the values on the > Oracle end? That's a good question, which I don't know the answer to. -- Angular momentum makes the world go 'round.