In Oracle Database, which value-prefixes can be referenced inside row-level triggers to access the old and new row values?
-
A:new only
-
B:old only
-
CBoth :new and :old
-
DNeither :new nor :old
Answer
Correct Answer: Both :new and :old
Explanation
Introduction / Context:Oracle Database supports row-level triggers that fire for each affected row during INSERT, UPDATE, or DELETE operations. Inside these triggers, Oracle exposes special pseudo-records to read or assign column values. Knowing which prefixes are available is essential for correct trigger logic.
Given Data / Assumptions:
- The question concerns Oracle row-level trigger syntax.
- Available prefixes may include :new and :old to reference column values.
- We assume standard Oracle PL/SQL trigger behavior.
Concept / Approach::new refers to the new column values (after change) and :old refers to the original column values (before change). Their availability depends on the DML operation: INSERT provides :new, DELETE provides :old, and UPDATE provides both.
Step-by-Step Solution:
For INSERT triggers, :new is populated; :old is not meaningful.For DELETE triggers, :old is populated; :new is not meaningful.For UPDATE triggers, both :new and :old are available for comparison and auditing.Verification / Alternative check:Oracle PL/SQL documentation consistently demonstrates :new and :old usage within row-level triggers for all three DML events.
Why Other Options Are Wrong::new only and :old only are each incomplete because availability depends on the DML statement. Neither :new nor :old is false since Oracle exposes these pseudo-records in row-level triggers.
Common Pitfalls:Trying to assign to :old in UPDATE/INSERT triggers (not allowed). Also, attempting to reference :new in DELETE triggers or :old in INSERT triggers will fail.
Final Answer:Both :new and :old