2-13. Ensuring That Multiple Queries “See” the Same Data
Problem
You are issuing a set of queries against the database, and you need to ensure that none of the table rows changes throughout the course of the queries being made.
Solution
Set up a read-only transaction in which the current transaction will see the data only as an unchanged snapshot in time. To do so, use the SET TRANSACTION
statement to begin a read-only transaction and establish a snapshot of the data so it will be consistent and unchanged from all other updates being made. For instance, the following example displays a block that sets up read-only queries against the database for dollar values from a bank account:
DECLARE
daily_atm_total NUMBER(12,2); weekly_atm_total NUMBER(12,2); ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.