Name
SQL-02: Don't leave transactions "dangling"
Synopsis
Once you start a transaction, you should take responsibility
for completing the transaction. Since transactions lock rows and
potentially block other transactions, you need to ensure that
transactions do not persist indefinitely. Generally, you should
place the START TRANSACTION and
COMMIT or ROLLBACK statements in the same stored
program. This program may also call other programs, and you need
to make sure that these called programs do not contain
transactional code.
There are some exceptions to this recommendation. In particular, modular design might prompt you to break down a transaction into separate modules and control the overall transaction state from a master procedure.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access