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
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
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
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.