How do I add condition into the BATCH insert. I am using statement like following to insert data into the table.
INSERT INTO table (id, date1,date2 ) SELECT ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM table WHERE id= ? and COALESCE (date1::timestamp = ?))
Above INSERT will add entry into all the columns always. Is there any way I can have conditional entry into the table. For example I want to insert only date2 if date1 and id is already present. Goal is to not update the date1 if it is already present.