agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: unique key problem on update
Date: Fri, 20 Sep 2013 18:26:58 +0200
Message-ID: <l1ht05$9cq$1@ger.gmane.org> (raw)
In-Reply-To: <201309201707.56028.gary.stainburn@ringways.co.uk>
References: <201309201707.56028.gary.stainburn@ringways.co.uk>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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,
  primary key (sp_id) deferrable
);





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



view thread (4+ messages)  latest in thread

Message-ID: <l1ht05$9cq$1@ger.gmane.org>
Permalink:  ../l1ht05$9cq$1@ger.gmane.org/
Also on:    postgresql.org/message-id/l1ht05$9cq$1@ger.gmane.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: unique key problem on update
  In-Reply-To: <l1ht05$9cq$1@ger.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox