Re: Need help understanding error message

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Need help understanding error message
Date: 2021-10-26 17:14:53
Message-ID: 6778e953-287e-2a5a-3281-a5671b76608d@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/26/21 11:58 AM, Rich Shepard 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,

Show us the actual UPDATE statement.

--
Angular momentum makes the world go 'round.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2021-10-26 18:00:22 Re: Need help understanding error message
Previous Message Rob Sargent 2021-10-26 17:07:32 Re: Need help understanding error message