Re: [GENERAL] blocking INSERTs

2005-06-08 Thread Csaba Nagy
On Wed, 2005-06-08 at 05:31, Joseph Shraibman wrote: > I want to do the following: > > BEGIN; > SELECT ... FROM table WHERE a = 1 FOR UPDATE; > UPDATE table SET ... WHERE a = 1; > if that resturns zero then > INSERT INTO table (...) VALUES (...); > END; > > The problem is that I need to avoid rac

Re: [GENERAL] blocking INSERTs

2005-06-07 Thread Dennis Bjorklund
On Tue, 7 Jun 2005, Joseph Shraibman wrote: > BEGIN; > SELECT ... FROM table WHERE a = 1 FOR UPDATE; > UPDATE table SET ... WHERE a = 1; > if that resturns zero then > INSERT INTO table (...) VALUES (...); > END; > > The problem is that I need to avoid race conditions. Sometimes I get > primary

Re: [GENERAL] blocking INSERTs

2005-06-07 Thread Douglas McNaught
Joseph Shraibman writes: > I want to do the following: > > BEGIN; > SELECT ... FROM table WHERE a = 1 FOR UPDATE; > UPDATE table SET ... WHERE a = 1; > if that resturns zero then > INSERT INTO table (...) VALUES (...); > END; > > The problem is that I need to avoid race conditions. Sometimes I g

[GENERAL] blocking INSERTs

2005-06-07 Thread Joseph Shraibman
I want to do the following: BEGIN; SELECT ... FROM table WHERE a = 1 FOR UPDATE; UPDATE table SET ... WHERE a = 1; if that resturns zero then INSERT INTO table (...) VALUES (...); END; The problem is that I need to avoid race conditions. Sometimes I get primary key exceptions on the INSERT.