Answered Can we have more than one trigger program for the same event?

rolguin

Member
Hi,

We have a system from a Third Part.
At the dictionary, for a particular table there is already a program for WRITE event. We can't amend that existing program and also we don't want that. Is there any way to put a second trigger program for the same event, please?

Regards,
ROlguin
 

Cringer

ProgressTalk.com Moderator
Staff member
No there isn't a way. The only option I can think of is to give your own program the same name as the vendor's trigger program an ensure it's higher up the propath than than the vendor's program. Anything like this is dangerous to say the least though.
 

rolguin

Member
Hi Cringer,
Thanks for your quick reply.
If I leave my trigger program with the same name as the vendor's. Does the event runs both trigger programs? Or just the first one that it finds?

Regards,
ROlguin
 

RealHeavyDude

Well-Known Member
The first occurance in the PROPATH wins - like with PATH on the operating system level.

Heavy Regards, RealHeavyDude.
 

dulecki

Member
No. Either yours has to call theirs or theirs has to call yours. Or you create a third one that calls both of the first two, along with anything you want to add later.
 

Cringer

ProgressTalk.com Moderator
Staff member
That's a good point - your one could call their one by implicitly referring to it's location rather than relying on the propath. But as I said earlier, much danger lies this way. Why would you want to do this? It sounds like a horrendous situation. I can almost guarantee you will be landing yourself in trouble!
 

rolguin

Member
Ok,

I was only checking the possibility to see if it was doable.
I gave it a try. So, I put our trigger at the event WRITE for a certain table and then at the end of the code (our trigger) I just simply did a Run their trigger.

Now, I am getting the following errors:
xxxxx.p is a WRITE trigger procedure. (3246)
Cannot RUN xxxxxx.p directly. Must be fired from a trigger. (3251)

Then the program that triggers the WRITE trigger aborts....

Obviously, this is happening because their program is "a trigger" not a normal procedure that can be run anywhere.

I can't amend their trigger to call my trigger because is encrypted. So, I am wondering, I will have to ask them to merge my trigger in their source code.

Any other ideas that I could make this work, please?
I was told that SQL databases can handle more that one trigger per event "easily". So, in the vendor's hand with this.

Thanks again,.

Regards,
ROlguin
 

RealHeavyDude

Well-Known Member
The definition of the database triggers contains a flag "overridable". If it is set to true you can override it in your procedure. You need to define the trigger like you would define any other trigger that should respond to an event. I've never tried to see what happens when you attempt to override a database triggers that is not defined overridable ...

Code:
ON CREATE OF YourTable
DO:
    RUN yourProcedure.p.
END.

Heavy Regards, RealHeavyDude.
 
Top