Collections:
Manage Transaction Isolation Levels in Oracle
How To Manage Transaction Isolation Level in Oracle?
✍: FYIcenter.com
Transaction isolation level can be managed in a procedure by using the SET TRANSACTION and COMMIT statements. Here is a sample script on how to manage transaction isolation level:
SQL> CREATE OR REPLACE PROCEDURE HR.TOTAL_SALARY AS 2 total_salary NUMBER(12,2); 3 BEGIN 4 SET TRANSACTION READ ONLY; 5 SELECT SUM (salary) INTO total_salary FROM employees; 6 DBMS_OUTPUT.PUT_LINE('Total salary 1: ' 7 || total_salary); 8 -- Other sessions may change salaries of some records 9 SELECT SUM (salary) INTO total_salary FROM employees; 10 DBMS_OUTPUT.PUT_LINE('Total salary 2: ' 11 || total_salary); 12 COMMIT; 13 END; 14 / SQL> EXECUTE TOTAL_SALARY; Total salary 1: 691400 Total salary 2: 691400
"READ ONLY" transaction level takes a read only snapshot of the database. This allows other sessions to update the database without any locks. All queries in the session will produces identical results. So both SELECT statements in this script will return the same value guaranteed.
⇒ Example of Passing Parameters to Procedures in Oracle
⇐ Create an Array in PL/SQL in Oracle
2019-03-08, 1847🔥, 0💬
Popular Posts:
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
How To Find Out What Privileges a User Currently Has in Oracle? Privileges granted to users are list...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...
How To Convert Binary Strings into Hexadecimal Character Strings in SQL Server? When a query returns...