Do I have to lock table in this case?
Ondrej Palkovsky <xpalo03@vse.cz>
From: Ondrej Palkovsky <xpalo03@vse.cz>
To: pgsql-sql@postgresql.org
Date: 2001-06-09T15:50:11Z
Lists: pgsql-sql
I have a table like this: id primary key unique I need to do: - if 'unique' exists in table, return appropriate id else insert into table new id. Now doing: select id where unique=%s insert/update creates a race condition. The application can theoretically rollback & redo the whole transaction (not simple in some cases). What is the preferred solution to this problem (I got about 3 such cases in one simple application). Ondrej -- It is better to remain childless than to father an orphan.