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 1lBglt-0006BY-HV for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 16:30:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBgls-0001AW-GM for pgsql-general@arkaria.postgresql.org; Mon, 15 Feb 2021 16:30:48 +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 1lBgls-0001AO-6B for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 16:30:48 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lBglq-0007Ue-5A for pgsql-general@lists.postgresql.org; Mon, 15 Feb 2021 16:30:47 +0000 Received: by mail-ot1-x32f.google.com with SMTP id q4so6515442otm.9 for ; Mon, 15 Feb 2021 08:30:45 -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=NlFuBTAnJNP1PW5FfgEkuwjN7v7czEfYsnPS2DxMamg=; b=KsC03O2g8fsYOOV0/uIXcjH0cNr5or36ZLc6IxM2A8rGaqr6XrHyVeKEDoQesLiNSE p2C8LpEKB7rQJ6rjunExCEmHMc6SmOk8AaGuGO50DpQPXtRRVmq1NdeIhrHYWdrQDxt9 Sbqh+ENsw2Xvky5fKMg6MqDJd9vOdO37LzDEfdkXBEAv1gk+REMvi3tMeS/4gtNX9WWN bwtYJ5Ltk87n1hS9pMHn61m4INkQPc5OrYtU1dFCxa7C1uXGU+kyyqSZgq8sqHQskzeN +3Wv4M/6VdLHALBf2ICm25Kc4nFmHhQuAXV79ssbuyCQr8R+JUH3NH7L0pw/nR665M9g 6ChQ== 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=NlFuBTAnJNP1PW5FfgEkuwjN7v7czEfYsnPS2DxMamg=; b=Hjf2OuMie/uMb2P3GhJR9CCWDCLQcUtkiiSphjvbxA8ynwocZSF/QzmS3DhDPuHBt+ XZr3uwrje46V22lIseUKeHBrI7rACr443bAiXy0vN5vG5LoL4GhNPXAlXptDlTSlYCWx HayIt5fgS9B/JISvHU51qUosSYjtlwMfqn09SWVBpVwHi1Z+cbtuG7ej3HP+0VmNL0Wn DdnNmPT7Om1eHh1OROvXWltvivqOPvrnYdL+7L6V69LVZUe5Y0gnuNFG4khHIX5dTc96 5fwmArGaQ22+YUqgeXw76StIJ5UaVdrL8o1+EiMpuSFUQxpCa3rn11A/gjCbl7f3S+7+ wFnA== X-Gm-Message-State: AOAM53334aUjiLy4tPAK0ZU3BBGPVi+wx7B8aNxS2QJgXftY2TaSl6wF KFlFwkib6EcbnVrZKOgngOpy37m7a2wxBg== X-Google-Smtp-Source: ABdhPJxggmz8hhpDdHw/GanO9DlTMr5TAt22A2DdvxFKgOuJgHA9X4yLnqIi261XiK6seV3jHMnFKw== X-Received: by 2002:a9d:6650:: with SMTP id q16mr11091838otm.57.1613406643759; Mon, 15 Feb 2021 08:30:43 -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 l25sm3839670otd.40.2021.02.15.08.30.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Feb 2021 08:30:43 -0800 (PST) Subject: Re: ADD FOREIGN KEY fails, but the records exist To: "pgsql-generallists.postgresql.org" References: <37d7ad6b-3da6-0778-47fe-e6256babb4ad@aklaver.com> <22cd11dc-b6de-9056-fbed-1c53065fd1e0@aklaver.com> From: Ron Message-ID: <89ed61bd-2cec-5632-fbbd-6e95f6a5443e@gmail.com> Date: Mon, 15 Feb 2021 10:30:42 -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: <22cd11dc-b6de-9056-fbed-1c53065fd1e0@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: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 Ah, I see now.  No, we don't/ > >> >>> >>>> >>>> >>>> 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. > > -- Angular momentum makes the world go 'round.