Re: set-level update fails with unique constraint violation

From: Jayadevan M <Jayadevan(dot)Maymala(at)ibsplc(dot)com>
To: neuhauser+pgsql-general#postgresql(dot)org(at)sigpipe(dot)cz
Cc: pgsql-general(at)postgresql(dot)org, pgsql-general-owner(at)postgresql(dot)org
Subject: Re: set-level update fails with unique constraint violation
Date: 2010-01-04 04:33:29
Message-ID: OFCD8B26B7.CF2C9018-ON652576A1.00188372-652576A1.00190B7F@ibsplc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
This seems to work..
UPDATE x set i=i+1
from (select i as m from x order by m desc) y where x.i = y.m
Jayadevan

From: neuhauser+pgsql-general#postgresql(dot)org(at)sigpipe(dot)cz
To: pgsql-general(at)postgresql(dot)org
Date: 12/31/2009 09:15 PM
Subject: [GENERAL] set-level update fails with unique constraint
violation
Sent by: pgsql-general-owner(at)postgresql(dot)org

Hello,

this fails with "duplicate key value":

CREATE TABLE x (
i INT NOT NULL UNIQUE
);
INSERT INTO x (i) VALUES (1), (2), (3);
UPDATE x SET i = i + 1;

are there any plans to make this work?

--
Roman Neuhauser

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

DISCLAIMER:

"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2010-01-04 08:25:41 Re: Using autogenerated primary key in transaction
Previous Message Alvaro Herrera 2010-01-04 02:51:15 Re: Innotop for postgresl