I have a question that's very similar to other SO questions, but I haven't been able to find my exact case. I would like to update a PostgreSQL table as follows:
update my_table
set my_timestamp = null
where TO_CHAR(my_timestamp :: DATE, 'dd-mm-yyyy') = '01-01-1970' and cast(my_timestamp as time) > '10:10:10'
The problem is setting my_timestamp = null
violates a uniqueness constraint. In these cases I would like to skip that particular row. So I added the following line to my code.
update my_table
set my_timestamp = null
where TO_CHAR(my_timestamp :: DATE, 'dd-mm-yyyy') = '01-01-1970' and cast(my_timestamp as time) > '10:10:10'
ON CONFLICT ON CONSTRAINT my_constraint do nothing
But this gives a syntax error and I can't figure out the exact right way to fix it. What's the right way to do this?