Replace a delete/insert by an insert-or-replace SQL statement.

Minor code clean-up for #9210.