OLD and NEW Context Variables
For DML triggers, the Firebird engine provides access to sets of OLD and NEW context variables (or, “records”).Each is a record of the values of the entire row: one for the values as they are before the data-changing event (the BEFORE phase) and one for the values as they will be after the event (the AFTER phase).They are referenced in statements using the form NEW.column_name and OLD.column_name, respectively.The column_name can be any column in the table’s definition, not just those that are being updated.
The NEW and OLD variables are subject to some rules:
-
In all triggers,
OLDis read-only -
In
BEFORE UPDATEandBEFORE INSERTcode, theNEWvalue is read/write, unless it is aCOMPUTED BYcolumn -
In
INSERTtriggers, references toOLDare invalid and will throw an exception -
In
DELETEtriggers, references toNEWare invalid and will throw an exception -
In all
AFTERtrigger code,NEWis read-only