Received: from megazone23.bigpanda.com ([216.136.151.41]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6QI0cf46655 for ; Thu, 26 Jul 2001 14:00:38 -0400 (EDT) (envelope-from sszabo@megazone23.bigpanda.com) Received: from localhost (sszabo@localhost) by megazone23.bigpanda.com (8.11.2/8.11.2) with ESMTP id f6QI0Y377580; Thu, 26 Jul 2001 11:00:34 -0700 (PDT) Date: Thu, 26 Jul 2001 11:00:34 -0700 (PDT) From: Stephan Szabo To: Steve SAUTETNER cc: pgsql-general@postgresql.org Subject: Re: concurent updates In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200107/945 X-Sequence-Number: 13065 On Thu, 26 Jul 2001, Steve SAUTETNER wrote: > hi everybody ! > > I've got a little problem when updating a primary key in two table > where the primary key of the one is a foreign key from the second : > > here are the 2 tables : > > create table table1 (id int primary key, col1 int); > create table table2 (id int primary key references table1(id), col2 int); > > and the 2 updates : > > 1) update table2 set id = 1001 where id = 1; > 2) update table1 set id = 1001 where id = 1; > > i can't execute them separately because of an integrity constraint > violation. > i've got the same error in a BEGIN / COMMIT block containing the updates. > > Does any one see how two help me ? Either on update cascade (as suggested by someone else) or making the constraint deferred in which case you can use a begin...commit block.