pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Rich Shepard <rshepard@appl-ecosys.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Need help understanding error message
Date: Tue, 26 Oct 2021 10:07:32 -0700
Message-ID: <43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.com> (raw)
In-Reply-To: <9532af10-68ce-9687-1256-a858b248b755@appl-ecosys.com>
References: <9532af10-68ce-9687-1256-a858b248b755@appl-ecosys.com>



> On Oct 26, 2021, at 9:58 AM, Rich Shepard <rshepard@appl-ecosys.com> wrote:
> 
> In a database table I have these rows:
> # select * from contacts where person_nbr=6;
> person_nbr | contact_date | contact_type |                                                      not
> es                                                       | next_contact ------------+--------------+--------------+---------------------------------------------------------
> ---------------------------------------------------------+--------------
>          6 | 2018-04-05   | Phone        | Left message @ 9:39.
>                                                         |
>          6 | 2019-05-14   | Phone        | He can call me if issues do come up. |
>          6 | 2021-08-17   | Email        | Sent message 2.
>                                                         | 2021-10-06
>          6 | 2021-07-23   | Email        | Sent message 1.
>                                                         | 2021-07-28
>          6 | 2021-07-28   | Email        | Sent message 1.
>                                                         | 2021-08-16
> (5 rows)
> 
> When I try to update this table with:
> (6,'2021-10-26','Email','message 3','2012-11-16'),
> psql reports this error:
> psql:insert_into_contacts.sql:31: ERROR:  duplicate key value violates unique constraint "activities_pkey"
> DETAIL:  Key (person_nbr, contact_date, contact_type)=(6, 2021-10-26, Email) already exists.
> 
> The PK for this table is:
> PRIMARY KEY, btree (person_nbr, contact_date, contact_type)
> so there should be no conflict as the contact_date in the update is not
> already in the table.
> 
> I don't understand the error as it's not occurred before when updating this
> table.
> 
> Insight needed,
> 
> Rich
> 
> 
What do you get when you select * where person_nbr = 6 and contact_date = ‘2021-10-26’ and contact_type = ‘Email’ from activities; ?








view thread (9+ messages)  latest in thread

Message-ID: <43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.com>
Permalink:  ../43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.com/
Also on:    postgresql.org/message-id/43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.com

 · 

reply

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: robjsargent@gmail.com, rshepard@appl-ecosys.com
  Subject: Re: Need help understanding error message
  In-Reply-To: <43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.com>
  References: <9532af10-68ce-9687-1256-a858b248b755@appl-ecosys.com> <43BD2E36-42A3-4D2E-BBAC-0C6355B9647E@gmail.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