How to implement a conditional Upsert stored procedure?

后端 未结 5 1394
闹比i
闹比i 2021-02-06 10:49

I\'m trying to implement your basic UPSERT functionality, but with a twist: sometimes I don\'t want to actually update an existing row.

Essentially I\'m trying to synchr

5条回答
  •  执念已碎
    2021-02-06 11:14

    You could switch the order of the update/insert around. So you do the insert within a try/catch and if you get a constraint violation then do the update. It feels a little dirty though.

提交回复
热议问题