3 ms·
you still have to do IF @@ROWCOUNT = 2 BEGIN COMMIT TRANSACTION; END ELSE BEGIN ROLLBACK TRANSACTION; END to make sure bot
by skyde 3y ago
you still have to do
IF @@ROWCOUNT = 2
BEGIN
COMMIT TRANSACTION;
END
ELSE
BEGIN
ROLLBACK TRANSACTION;
END
to make sure both rows have been updated.
so its a lot simpler to explicitly take a lock on the rows.
- giovannibonetti 3y agoYou're right. Locking the rows or using serializable isolation would be required to achieve an atomic operation if and only if both accounts are in the pristine state before it.