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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

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