Hello. I'm currently developing my first web app with Postgres and I have a question.
How do I perform a conditional insert/update? To clarify: I need to insert data into a table when the primary key is not already in the table, or an update if it is. I have currently solved this by SELECTing for the primary key, then looking if there is a row, and if there is I do an UPDATE otherwise I do an INSERT. But since this is a web app this way of course leaves a big race condition. Is there a way to get around that? Like the ON DUPLICATE KEY UPDATE statement in MySQL? Thanks for your time, Holli