RELEASE
RELEASE is a SQL command used primarily in transactional processing. It allows the user to release a savepoint which was previously defined inside the current transaction. Once the savepoint is released, it loses its validity and transactions cannot be rolled back to this savepoint anymore.
Example
Output
Explanation
A START TRANSACTION
statement is used which opens a new transaction. An INSERT
statement is used next inside the transaction, which adds a new row to the students
table. The RELEASE
statement commits the transaction, which causes the changes to become permanent.
Example
Output
No visible output will be provided.
Explanation
The example demonstrates a sample transaction in SQL server. If anything goes wrong during transaction, ROLLBACK
command will take the database back to the state where it was at the time BEGIN TRANSACTION
was executed. ROLLBACK
essentially releases the transaction, hence it is a way to RELEASE in SQL server. There is no visible output for this command but the actions performed during transaction are undone.
Example
Output
Explanation
The provided PL/SQL block creates a savepoint called start_trans
. The next statement is an UPDATE
statement which subtracts 500 from the balance of the account with id 101. After that, a SELECT
statement counts the number of accounts with a balance less than 0 and saves the result in v_test
. If v_test
is bigger than 0, the block rolls back the transaction to the start_trans
savepoint. If v_test
is 0, the block releases the start_trans
savepoint. In both cases, the block outputs a corresponding information line.