Does anyone know how what Spring Jdbc template method I could use to execute this ‘upsert’ or an alternative approach that would also perform the operations in one database call?
UPDATE jasper_report SET Uri = 'update' WHERE ReportId = 99;
IF @@ROWCOUNT = 0 AND Exists(Select 1 FROM report Where Id = 99)
BEGIN
INSERT INTO jasper_report (ReportId, Uri) VALUES (99, 'insert')
END;
Turns out I was close but forget a step.
I had to change the query itself to:
Then in my Dao only needed to use Spring’s JdbcTemplate update method. It looks something like this: