Skip site navigation (1) Skip section navigation (2)

Re: duplicate key violates unique constraint??

From: "Alexander Kuprijanov" <sanya-spb(at)mail(dot)ru>
To: <pgsql-ru-general(at)postgresql(dot)org>
Subject: Re: duplicate key violates unique constraint??
Date: 2005-06-20 11:58:41
Message-ID: 004f01c5758f$678093e0$6b00a8c0@sanya (view raw or flat)
Thread:
Lists: pgsql-ru-general
проблема решилась после комады
select setval('awp_elsi.i_file_v2_id_seq', (select max(id)+1 from awp_elsi.i_file_v2))

.. текущее значение последовательности было меньше чем max(id)... 
а разве Postgre сама не следит за этим?



----- Original Message ----- 
From: "Alexander Kuprijanov" <sanya-spb(at)mail(dot)ru>
To: <pgsql-ru-general(at)postgresql(dot)org>
Sent: Monday, June 20, 2005 1:55 PM
Subject: [pgsql-ru-general] duplicate key violates unique constraint??


> Добрый день, уважаемые
> 
> не могу понять в чем глюк:
> есть такая конструкция:
> CREATE TABLE awp_elsi.i_file_v2
> (
>  id serial NOT NULL,
>  idterm int4 NOT NULL,
>  <...>
>  sreserv varchar(3),
>  datetimerec timestamp NOT NULL DEFAULT ('now'::text)::timestamp(6) without time zone,
>  CONSTRAINT i_file_v2_pkey PRIMARY KEY (id)
> ) 
> WITHOUT OIDS;
> 
> к ней соответственно прикручено: 
> CREATE SEQUENCE awp_elsi.i_file_v2_id_seq
>  INCREMENT 1
>  MINVALUE 1
>  MAXVALUE 9223372036854775807
>  START 926 
>  CACHE 1;
> 
> пытаюсь сделать (ключ, как видите, не трогаю..):
> INSERT INTO awp_elsi.i_file_v2
> (idterm,ups_code,unb_code,szdocumentnum,cstarttankvbx,ulps_volume,ulps_density,ulps_weight,utanknumber,startrec,ups_cels,ips_cels_income,uaktnumber,finishrec,dsr_volume,dsr_weight,dsr_density,cstarttank,fdeltavolume,fdeltamass,imid_cels,sreserv)
> VALUES
> (679,7,777,'777',null,30,7674,23,2,'2005-06-17 11:5:36',0,0,0,'2005-06-17 11:5:36',30,23.01,7674,'0',0.0,0,0.0,'');
> 
> и в ответ получаю:
> ERROR:  duplicate key violates unique constraint "i_file_v2_pkey"
> 
> кто-нить может чего сказать?
> 
> PS: postgresql-7.4.3
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Responses

pgsql-ru-general by date

Next:From: Markus Bertheau ☭Date: 2005-06-20 12:12:53
Subject: Re: duplicate key violates unique constraint??
Previous:From: Alexander KuprijanovDate: 2005-06-20 09:55:38
Subject: duplicate key violates unique constraint??

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group