Re: concurent updates

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Steve SAUTETNER <ssa(at)informactis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: concurent updates
Date: 2001-07-26 18:00:34
Message-ID: Pine.BSF.4.21.0107261059400.77564-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Cramer 2001-07-26 18:48:28 What's going on here?
Previous Message Barry Lind 2001-07-26 16:34:31 Re: [SQL] When PostgreSQL compliant JDBC 2.0? (Batch updates)