| From: | "Matthijs Melissen" <melissen(at)phil(dot)uu(dot)nl> |
|---|---|
| To: | <pgsql-general(at)postgresql(dot)org> |
| Subject: | Problem with transactions |
| Date: | 2007-03-26 22:05:56 |
| Message-ID: | 01ce01c76ff2$ee3d1de0$5ee26191@Matthijs |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I want two users to execute the following queries:
1) delete from forum where id = 'A';
1) insert into forum (id, name) values ('A', 'testa');
2) delete from forum where id = 'A';
2) insert into forum (id, name) values ('A', 'testb');
id is a unique key. The numbers designate the user (1 and 2). The problem is
that I don't know in which order the queries are executed (I only know each
user executes its DELETE query before the INSERT query). I can't use UPDATE
because I don't know in advance that there exist a row with id A.
How do I prevent the queries from being executed in the wrong order and thus
causing an 'duplicate key violates unique constraint' error?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dmitry Koterov | 2007-03-26 22:24:44 | Temporarily disable all table indices |
| Previous Message | Hannes Dorbath | 2007-03-26 22:05:36 | Re: PG over NFS |