You might want to review the manual for a particular chapter on the transaction :
A transaction is a logical unit of work that contains one or more SQL statements executed by a single user. [...] The transaction begins with the first executable SQL query of the user. A transaction ends when it is explicitly transferred or rolled back by this user.
You do not need to explicitly start the transaction, this is done automatically. You will need to indicate the end of the transaction with commit (or rollback).
The locking mechanism is a fundamental part of the database, read about it in the chapter Concurrency data and consistency .
Regarding Stored Procedures
A stored procedure is a collection of statements that execute in the same transaction as the calling session (*). Typically, transaction management (commit and rollback) belongs to the calling application. The calling application has a broader view of the process (which may include several stored procedures), and therefore, in a better position, you can determine if the data is in a consistent state. Although you can commit in a stored procedure, this is not the norm.
(*), unless the procedure is declared as an autonomous transaction, in which case the procedure is executed as an independent session (thanks now here , now I see your point).
Vincent malgrat
source share