Re: unique key problem on update - Mailing list pgsql-sql

From Thomas Kellerer
Subject Re: unique key problem on update
Date
Msg-id l1ht05$9cq$1@ger.gmane.org
Whole thread Raw
In response to unique key problem on update  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Responses Re: unique key problem on update  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
the value of OLD on an initial row insert  (James Sharrett <jsharrett@tidemark.net>)
List pgsql-sql
Gary Stainburn wrote on 20.09.2013 18:07:
> I want to add a new page after page 2 so I try to increase the sequence number
> of each row from page 3 onwards to make space in the sequence for the new
> record. However, I get duplicate key errors when I try. Can anyone suggest
> how I get round this.
>
> Also, the final version will be put onto a WordPress web site which means I
> will have to port it to MYSQL which I don't know, so any solution that will
> work with both systems would be a great help.
>

You need to define the primary key as deferrable:

create table skills_pages
( sp_id        serial not null, sp_sequence  integer not null, sp_title     character varying(80), sp_narative  text,
primarykey (sp_id) deferrable
 
);






pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: unique key problem on update
Next
From: Gary Stainburn
Date:
Subject: Re: unique key problem on update