The Trigger WHEN Clause
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
WHEN (condition) is a lightweight row-level filter evaluated before the trigger body runs, without a PL/SQL context switch.
How it works
On a FOR EACH ROW trigger, WHEN (condition) decides per row whether the body executes. It references NEW/OLD without the colon, can use simple SQL functions but not PL/SQL functions or subqueries, and is cheaper than an IF at the top of the body because it avoids entering PL/SQL when the condition is false. Use it for the common 'only when this column actually changed' or 'only for this type' guard.
How it works
CREATE OR REPLACE TRIGGER trg_salary_raise_audit AFTER UPDATE OF salary ON employees FOR EACH ROW WHEN (NEW.salary <> OLD.salary) -- no colon here BEGIN INSERT INTO salary_audit(employee_id, old_salary, new_salary, changed_on) VALUES (:OLD.employee_id, :OLD.salary, :NEW.salary, SYSDATE); END; /
Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.