From: | "Greg Sabino Mullane" <greg(at)turnstep(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Cc: | claus(dot)pruefer(at)webcodex(dot)de |
Subject: | Re: updating unique columns |
Date: | 2006-06-01 14:33:57 |
Message-ID: | f42c4766698d5af47343e397acdd83e9@biglumber.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
-----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;
| UPDATE
| orderby SET orderby = orderby +10
| WHERE groupid IN
| ( SELECT groupid
| FROM TABLE WHERE group_id = 1
| ORDER BY orderby DESC )
No idea what you are trying to do here: try posting the actual SQL
used. However, an ORDER BY has no meaning inside of a subselect
passed to IN, as IN treats the list as bag of values, and does not
care about the internal order.
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200606011030
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFEfvpFvJuQZxSWSsgRAjQlAKDTNIpwbSEk0gcQp2pI7LokG+qwWgCgt/b6
/7ZWYDb4gufE4b0zCHyFZgg=
=4LQ8
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen | 2006-06-02 05:06:20 | BUG #2461: pg_dump ftell mismatch error |
Previous Message | Alvaro Herrera | 2006-06-01 14:12:21 | Re: |