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

Re: updating unique columns

From: "William ZHANG" <uniware(at)zedware(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: updating unique columns
Date: 2006-06-02 09:56:42
Message-ID: e5p20e$v1o$1@news.hub.org (view raw or flat)
Thread:
Lists: pgsql-bugs
""Greg Sabino Mullane"" <greg(at)turnstep(dot)com>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> | UPDATE
> | orderby SET orderby = orderby +10
> | WHERE groupid = 1;
> | -> FAILS because of UNIQUE INDEX
>
> One workaround is to do it in two steps, assuming that
> orderby is > 0 for all rows you are changing:
>
> BEGIN;
> UPDATE mytable SET orderby = -orderby WHERE groupid = 1;
> UPDATE mytable SET orderby = -orderby+10 WHERE groupid = 1;
> COMMIT;

Should we invent something to defer the check of uniqueness
to the end of the SQL command?

Regards,
William ZHANG



In response to

pgsql-bugs by date

Next:From: William ZHANGDate: 2006-06-02 10:12:56
Subject: Re: missing or erroneous pg_hba.conf file
Previous:From: Magnus HaganderDate: 2006-06-02 08:48:43
Subject: Re: Infinite increment of postgre.exe in taskmanager

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