From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Andrus <kobruleht2@hot.ee>
To: pgsql-general@postgresql.org
Subject: Re: Duplicate key error
Date: Wed, 3 Mar 2021 07:42:20 -0800
Message-ID: <5b68b4b3-b957-5009-cf3e-4bbc9dcbd0d9@aklaver.com> (raw)
In-Reply-To: <a8656d4f-d692-ffae-077e-304f348e25bf@hot.ee>
References: <a8656d4f-d692-ffae-077e-304f348e25bf@hot.ee>
On 3/3/21 7:23 AM, Andrus wrote:
> Hi!
>
> Sometimes duplicate key error
>
> duplicate key value violates unique constraint "session_pkey"
> Key (workplace)=(WIN-N9BSKUNKBC8 ) already exists.
>
> occurs in script:
>
> delete from session where workplace='WIN-N9BSKUNKBC8' ;
> INSERT INTO session (workplace,ipaddress,logintime,loggeduser)
> SELECT 'WIN-N9BSKUNKBC8' ,
> inet_client_addr()::CHAR(14),current_timestamp::CHAR(28),CURRENT_USER
> WHERE NOT EXISTS (SELECT 1 FROM session WHERE workplace='WIN-N9BSKUNKBC8' )
>
> Sript is running form windows task scheduler on every 10 minutes. Error
> occurs only sometimes.
There is no other process inserting to this table?
--
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 using the --to and --cc options:
reply via email
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, kobruleht2@hot.ee
Subject: Re: Duplicate key error
In-Reply-To: <5b68b4b3-b957-5009-cf3e-4bbc9dcbd0d9@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