This example uses a SET clause as a triggered action statement in a BEFORE row trigger.
This is the subject table definition. Assume that values are loaded into the amount column of the table from a source file employing a USING INSERT request.
CREATE TABLE subject_table ( entry_date DATE, amount INTEGER);
This is the trigger definition:
CREATE TRIGGER set_trig BEFORE INSERT ON subject_table REFERENCING NEW AS curr_value FOR EACH ROW SET curr_value.entry_date = DATE; -- Adds the current system date to the entry_date column
Because of the SET clause assignment, the following triggering statement:
USING (amount INTEGER) INSERT INTO subject_table VALUES (NULL,:amount);
executes as if it were this statement:
USING (thisdate DATE, amount INTEGER) INSERT INTO subject_table VALUES (:thisdate, :amount);