pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John McCawley <nospam@hardgeus.com>
To: Pgsql-sql@postgresql.org <Pgsql-sql@postgresql.org>
Subject: Re: deferrable on unique
Date: Tue, 22 Nov 2005 10:27:23 -0600
Message-ID: <438346EB.2000809@hardgeus.com> (raw)
In-Reply-To: <20051122161524.10090.qmail@web54309.mail.yahoo.com>
References: <20051122161524.10090.qmail@web54309.mail.yahoo.com>

It's a low-tech solution but you could:

  begin
  update t1 set seq=-1 where id=5
  update t1 set seq=5 where id=4
  update t1 set seq=4 where id=-1
  end

This is assuming that you don't naturally have -1 as a valid value of 
that column.

chester c young wrote:

>table t1:
>  id integer primary key,
>  seq integer not null unique
>
>the seq is for ordering the rows as the user likes.  however, if the
>rows are moved around, eg
>  begin
>  update t1 set seq=4 where id=5
>  update t1 set seq=5 where id=4
>  end
>will bomb because the first update has two rows of seq=4 (although
>correct after the transaction).
>
>I thought "deferrable initally deferred" would fix this, but the phrase
>is not allowed on unique.
>
>is this correct?  any ideas?
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: Don't 'kill -9' the postmaster
>  
>



view thread (2+ messages)

Message-ID: <438346EB.2000809@hardgeus.com>
Permalink:  ../438346EB.2000809@hardgeus.com/
Also on:    postgresql.org/message-id/438346EB.2000809@hardgeus.com

 · 

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: nospam@hardgeus.com
  Subject: Re: deferrable on unique
  In-Reply-To: <438346EB.2000809@hardgeus.com>

* 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