Oracle trigger inserting updating deleting
Two popular reasons to use compound trigger are: Hopefully this example with make things more clear. NAME IS NULL) ) THEN v_index := v_index 1; v_emp_changes(v_index).upd_dt := SYSDATE; v_emp_changes(v_index).upd_by := SYS_CONTEXT (' : NEW. So that same computation is not made during after-each-row section, and is computed and stored in a variable just once before row-level execution begins.
Lets create a compound trigger for auditing a large table called ’employees’. Similarly any such pre-processing if required can be performed on that source table (mutating table), doing so will avoid any possible mutating-error.
Plus there is an added advantage: it allows sharing of common state between all the trigger-points using variable.
This would be a good starting point for your question (in sqlserver trigger I use inserted table/view for getting the row values, how to get these values in Oracle trigger?
) IF UPDATING(nr Topic) OR (IF 'nr Topic' Exist in Deleted records 'that have been deleted before' ) AND NOT (if 'nr Topic' Exist in inserted records 'that have been inserted before')Then....
In Oracle, these values are stored in OLD and NEW records.
So I would write something like CREATE TRIGGER TRG_Forum Posts BEFORE INSERT OR UPDATE OF nr Topic OR DELETE ON Forum Posts FOR EACH ROW DECLARE nr_topic_old integer; nr_topic_new integer; cnt integer; nr_lastpost integer; TYPE REF_cur_topics IS REF CURSOR; cur_topics REF_cur_topics; BEGIN -- do not know what is in :new in delete and in :old in insert -- i am afraid it contains nulls which is not wise to use -- you can check it yourself as i do not have access to Oracle now IF DELETING THEN nr_topic_old := :Topic; nr_topic_new := :Topic; ELSIF INSERTING THEN nr_topic_old := :Topic; nr_topic_new := :Topic; ELSE nr_topic_old := :Topic; nr_topic_new := :Topic; END IF; -- your commands, use nr_topic_old and nr_topic_new variables OPEN cur_topics FOR SELECT c. Nr in ( nr_topic_new, nr_topic_old ); END; / 'I do not think it is good to publish here sqlserver code as it seems nobody here knows its meaning.