Skip to content
Advertisement

How can I indicate the “current” column in an upsert in PostgreSQL?

I have the following upsert with which I have problems because the subqueries give me more than one result. The problem is that I don’t know how to indicate in the upsert to compare the value of the column that is currently being updated. The problem is after the DO UPDATE.

Advertisement

Answer

I think you are looking for the excluded record that represents the row that would have been inserted:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement