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

Re: ERROR: duplicate key violates unique constraint "client_alerts_PK"

From: "Laurent Yaish" <laurenty(at)gmail(dot)com>
To: "Guillaume Lelarge" <guillaume(at)lelarge(dot)info>
Cc: "Robert Starr" <rob(at)surrenderdorothy(dot)com(dot)au>, pgadmin-support(at)postgresql(dot)org
Subject: Re: ERROR: duplicate key violates unique constraint "client_alerts_PK"
Date: 2007-09-13 06:11:12
Message-ID: c7e3acb10709122311m3294cb6dr9f1b25aef01f2791@mail.gmail.com (view raw or flat)
Thread:
Lists: pgadmin-support
my bad... I missed the post about the default value..


On 9/12/07, Guillaume Lelarge <guillaume(at)lelarge(dot)info> wrote:
> Laurent Yaish a écrit :
> > Hi Rob,
> >
> > In your insert, do not explicitly specify a value for the primary key,
> > instead use NEXTVAL('client_alerts_seq') which will return the next
> > valid value and increment the sequence.
> >
> > i.e:
> >  insert into clients_alerts (id, client_id, alert_message,
> > alert_complete, date, staff_id)
> > values(NEXTVAL('client_alerts_seq'),'39','This is some alert
> > text','0','2007-05-04 12:42:05','14');
> >
>
> Or, better, he doesn't have to put a value for it as it is already the
> default value for this column :
>
> insert into clients_alerts (client_id, alert_message, alert_complete,
> date, staff_id)
> values('39','This is some alert text','0','2007-05-04 12:42:05','14');
>
> Regards.
>
>
> --
> Guillaume.
>

In response to

pgadmin-support by date

Next:From: Charlie ClarkDate: 2007-09-13 06:17:45
Subject: Re: Porting from MySQL to postgreSQL. Question RE: Sequence Dependencies
Previous:From: Guillaume LelargeDate: 2007-09-13 06:05:43
Subject: Re: ERROR: duplicate key violates unique constraint "client_alerts_PK"

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