Guys, I want to assure that a SQL statement is atomar. It trys to check if an email address is already found in a table, if yes, it returns the id field of the entry. If not found, it inserts the entry with the previously generated increment id and returns - again - the id. My concern: in a multi threaded environment, can a second thread interrupt this statement and eventually insert the same email address in the table with a different id? Or is this statement atomar? Any help would be highely appreciated.
CODE: _id := nextval('email_id_increment'); INSERT INTO email_adr (email_id, email, lastupdate) SELECT _id, '[EMAIL PROTECTED]', now()::timestamp WHERE NOT EXISTS (SELECT * FROM email_adr WHERE email='[EMAIL PROTECTED]'); - Johann ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend