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 race
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.
Joseph Shraibman jks@selectacast.net 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.
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 key