Re: Update violating constraint

From: Richard Huxton <dev(at)archonet(dot)com>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Naz Gassiep <naz(at)mira(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Update violating constraint
Date: 2007-05-03 12:02:48
Message-ID: 4639CF68.5080701@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alban Hertroys wrote:
> Naz Gassiep wrote:
>> Hi,
>> I'm trying to do an update on a table that has a unique constraint
>> on the field, I need to update the table by setting field = field+1

> I think you're looking for deferrable constraints; see:
>
> http://www.postgresql.org/docs/8.2/static/sql-set-constraints.html

Which won't work with unique constraints unfortunately. That's because
they're implemented through a unique index.

The work-around is to do: field = -field then field = -field + 1 or similar.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2007-05-03 12:06:57 Re: Update violating constraint
Previous Message Alban Hertroys 2007-05-03 10:30:20 Re: Cross-schema inheritence problem