Re: Update violating constraint

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Naz Gassiep <naz(at)mira(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Update violating constraint
Date: 2007-05-03 08:13:07
Message-ID: 46399993.7080209@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)magproductions(dot)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 //

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pumesh 2007-05-03 09:12:12 script for taking incremental backup in postgres in LINUX
Previous Message Martijn van Oosterhout 2007-05-03 07:00:40 Re: Utility of OIDs in postgres