When are triggers executed
Posted in 1999
Topics: Triggers, Constraints & Referential Integrity
If a user is in a transaction and inserts a row into a table, when does that row become visible to other users? When the transaction is "committed"?
James P. Snodgrass wrote: > > If a user is in a transaction and inserts a row into a table, when does > that row become visible to other users? When the transaction is > "committed"? That depends on the users' isolation levels. Users running COMMITTED READ will only see the insert after the tranaction is committed. Users running DIRTY READ will see it immediately. Users using CURSOR STABILITY or REPEATABLE READ will not see it until COMMITTED. Note that if we are talking about deletes/updates rather than inserts this changes slightly. CURSOR STABILITY will prevent any user from deleting or updating the particular row last FETCHED from a cursor as a shared lock is acquired on it or the FETCH will fail if some other user already has an exclusive lock so the results depend on who gets there first. Likewise REPEATABLE READ acquires a shared lock but on ALL rows accessed by a query so that none can be updated or deleted until the viewer's transaction is committed or rolled back. In this way even if the viewer closes its cursor and reopens it the rows will have remained locked in the interrum so that the viewer sees a consistent view. Art S. Kagel