Reputation: 535
Is it possible to fire a trigger before a specific procedure starts execution?
For example I have a package "A"
, and a procedure "B"
inside package "A"
.
So when I call A.B procedure i want to fire a trigger.
I'm using oracle 11gR2.
Upvotes: 0
Views: 1686
Reputation: 52376
If you have an existing trigger on a table and you want its logic to be executed under other circumstances, then place the logic in a procedure and call that procedure from the trigger, and from any other code that needs to execute it.
Upvotes: 0
Reputation: 49112
is it possible to fire a trigger before a specific procedure starts execution?
No, you cannot manually fire a trigger without any DML operation on the table. Triggers are designed to act implicitly on any DML action. Trigger is a (side)effect of an action and not an action in itself.
I don't think you need a trigger for your requirement. You could call a procedure before executing the procedure A.B
. Put your business logic accordingly. PL/SQL is a procedural language. So, if you put another procedure say procedure C
before A.B
, then A.C
will be executed before A.B
.
Upvotes: 3
Reputation: 2017
Triggers cannot be called directly. Instead they are fired automatically when you perform an insert/update or delete on a table that has triggers. So like in your case, on calling A.B procedure, you can perform an insert / update or delete that will force a trigger to fire.
Upvotes: 1