Questions: Stored Procedures: Procedural Logic and Transaction Control

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A bank has a web app, a mobile app, and an internal admin tool — all of which need to transfer funds between accounts. What is the strongest argument for implementing the transfer logic as a stored procedure rather than in each application?

AStored procedures execute faster because they run closer to the data
BStored procedures guarantee that every transfer enforces the same rules regardless of which application calls the database
CStored procedures prevent SQL injection attacks more reliably than application code
DStored procedures automatically partition the workload across database servers
Question 2 Multiple Choice

Inside a stored procedure for a fund transfer, after debiting Account A, you set a SAVEPOINT. Then the credit to Account B fails. You execute ROLLBACK TO SAVEPOINT. What is the state of the transaction?

AThe entire transaction is rolled back — Account A's debit is also reversed
BOnly the failed credit attempt is rolled back; Account A's debit remains
CThe transaction is committed up to the savepoint — Account A's debit is permanent
DSAVEPOINT has no effect when a statement fails; only full ROLLBACK works
Question 3 True / False

A stored procedure that wraps a fund transfer in BEGIN/COMMIT/ROLLBACK ensures that either both the debit and credit happen or neither happens.

TTrue
FFalse
Question 4 True / False

Rolling back a transaction to a SAVEPOINT permanently commits most of the work done before the savepoint.

TTrue
FFalse
Question 5 Short Answer

Why does putting business logic in a stored procedure provide stronger consistency guarantees than putting the same logic in application code, even if both implementations are correct?

Think about your answer, then reveal below.