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. ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])