pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: com2rela@daehyunst.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14585: duplicate key error after update when insert multiline
Date: Thu, 09 Mar 2017 10:44:27 +0000
Message-ID: <20170309104427.1418.49950@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14585
Logged by:          ByoungChan Kim
Email address:      com2rela@daehyunst.com
PostgreSQL version: 9.5.6
Operating system:   CentOS 7.3.1611
Description:        

grade_id is serial primary key, 
but insert data without grade_id after update some data like as below...

----transaction start----
update mSalesGrade set take_order = case when grade_id=138  then
'20170309154329' end,dpt_cd = case when grade_id=138  then '10310'
end,emp_nm = case when grade_id=138  then 'USERNAME' end,cst_code = case
when grade_id=138  then '12773' end,sitm_code = case when grade_id=138  then
'ITEMCODE' end,itm_width = case when grade_id=138  then '260' end,itm_length
= case when grade_id=138  then '200' end,lot_no = case when grade_id=138 
then 'ITEMNumber' end,out_date = case when grade_id=138  then '20170309'
end,remark1 = case when grade_id=138  then '17.03.08' end,take_sales = case
when grade_id=138  then '00000000000000' end,take_cst = case when
grade_id=138  then '00000000000000' end,regist_server = case when
grade_id=138  then '00000000000000' end,remark2 = case when grade_id=138 
then '' end,ord_qty = case when grade_id=138  then 4 end,update_dt = case
when grade_id=138  then current_timestamp end where grade_id in(138)
insert into
mSalesGrade(insert_emp,insert_dt,take_order,dpt_cd,emp_nm,cst_code,sitm_code,itm_width,itm_length,lot_no,out_date,remark1,take_sales,take_cst,regist_server,remark2,ord_qty,update_dt)values('USERCode',current_timestamp,'20170309184643','10303','USERNAME','10592','ITEMNumber','165','400','17224F13-6','20170309','','00000000000000','00000000000000','00000000000000','',6,current_timestamp)
---trnsaction end-----

error: duplicate key value violates unique constraint
detail: 'Key (grade_id)=(186) already exists.'

How can I solve it? After that error, I'm not using transaction at that
case(1.use serial 2.insert after update)


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Message-ID: <20170309104427.1418.49950@wrigleys.postgresql.org>
Permalink:  ../20170309104427.1418.49950@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170309104427.1418.49950@wrigleys.postgresql.org

 · 

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-bugs@postgresql.org
  Cc: com2rela@daehyunst.com
  Subject: Re: BUG #14585: duplicate key error after update when insert multiline
  In-Reply-To: <20170309104427.1418.49950@wrigleys.postgresql.org>
  References: <20170309104427.1418.49950@wrigleys.postgresql.org>

* 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