What are triggers?

Answer:
Triggers are an action that is performed is a condition is met within the code.

In this example, "TRIG56" will perform this action:

After a row is inserted into TABLEZZZ, if the row is <=50 then
insert the same row into TABLEYYY. If the condition/value is not
met, the row will not be inserted.


You can do a "BEFORE" trigger also. Triggers are code that must be compiled. You can also "disable" a trigger if you are doing an import into the tables for faster insertion. However, the inserts will have to be done into both tables because TABLEYYY will not be populated from the trigger because it is disabled.

CREATE TRIGGER trig56 AFTER INSERT ON tableZZZ REFERENCING NEW AS insertedRow FOR EACH ROW WHEN (insertedRow.a <= 50) BEGIN INSERT INTO tableYYY VALUES(:insertedRow.b, :insertedRow.a); END trig56; . run;

Note: There are comments associated with this question. See the discussion page to add to the conversation.
First answer by Ppyles. Last edit by Ayvsuresh 9. Contributor trust: 1 [recommend contributor recommended]. Question popularity: 13 [recommend question].