This content has been marked as final. Show 7 replies
Welcome to the forum.
You can refer to the Online Oracle Documentation, to learn more about triggers and the options you have:
So, in your case it would be something like:
... begin if inserting then do the required stuff.. elsif updating then do the required stuff... elsif deleting then do the required stuff... end if; end;
So my question is: How can I determine if it was an INSERT, UPDATE or DELETE command which fired this trigger.So you have one BEFORE/AFTER INSERT OR UPDATE OD DELETE trigger, right? Then in triiger body yoy can reference INSERTING, UPDATEING, DELETEING. For example:
. . . IF INSERTING THEN ... ELSIF UPDATING THEN ... ELSE ... -- DELETING logic END IF; . . .
This statement might help you in understanding how to determine the operation
If more than one type of DML operation can fire a trigger (for example, ON INSERT OR DELETE OR UPDATE OF Emp_tab), the trigger body can use the conditional predicates INSERTING, DELETING, and UPDATING to check which type of statement fire the trigger.
the keywords inserting, updating and deleting, which you use in the if clauses, are Oracle functions or?Yes, they are already there for you, if that's what you mean.
They're built in and come shipped with the database.
You can just refer to them as showed in the examples.
They're not 'functions' but 'conditional predicates'.
how do I know what happened?Oracle knows, and it's up to you how to handle the different action that should be taken, hence the IF ...THEN... construction.
You can test what happened by using DBMS_OUTPUT.PUT_LINE('some message'); in each part of your conditional processing.
Spend a little time exploring the provided links,to learn more, it's all explained there in detail, with examples.