Re: Update violating constraint - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Update violating constraint
Date
Msg-id 46399993.7080209@magproductions.nl
Whole thread Raw
In response to Update violating constraint  (Naz Gassiep <naz@mira.net>)
Responses Re: Update violating constraint
List pgsql-general
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
> however if this does not perform the updates on the table in a proper
> order (from last to first) then the update will cause a violation of the
> index *during* the update even though the table would be consistent
> after the update completes. So the update fails. How do I get around
> this without removing the constraint?

I think you're looking for deferrable constraints; see:

http://www.postgresql.org/docs/8.2/static/sql-set-constraints.html

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Utility of OIDs in postgres
Next
From: Alban Hertroys
Date:
Subject: Cross-schema inheritence problem