Can you prevent a trigger programatically?

Shodan

New Member
I am trying to use a trigger (ex: Table_A) to initiate a program when Table_A's record is created or updated, to assign a guid value to a field in the record i am working with, then generate xml of the record and put it on a queue.

I want the trigger to initiate when the record is first created or changed, however since im having to assign a guid value to a field in the record whenever i do this, ill be recursively triggering the write trigger every time i update the guid field. is there a way i can tell the logic in the trigger procedure to not trigger itself during a specific assign statement in the trigger procedure? I think i can see how to do this without this ability but it would be a lot simpler if i could simply disable the trigger from happening inside the trigger itself.
 

Stefan

Well-Known Member
If the trigger is overridable then you can use:

Code:
on write of <table> override do: end.

The override automatically reverts when the block is left. If you need to revert earlier, you can use:

Code:
on wrote of <table> revert.
 

Shodan

New Member
If the trigger is overridable then you can use:

Code:
on write of <table> override do: end.

The override automatically reverts when the block is left. If you need to revert earlier, you can use:

Code:
on wrote of <table> revert.
when you say revert, you mean undo the transaction?
i don't want it to undo the new write, i just don't want the write trigger procedure to trigger again inside the trigger procedure.

ex:
Schema trigger on write of table team run this program:

TRIGGER PROCEDURE FOR WRITE OF TEAM.
do:
assign team.city = "Cleveland".
end.

This would loop endlessly because im writing inside of the write trigger.

how do i override this to not do that and only do this once?
 

Stefan

Well-Known Member
No, with revert I mean revert override trigger, not transaction

Why do you assume that it would loop endlessly? Have you tried it?
 

TomBascom

Curmudgeon
It sounds like you are expecting that an update within the context of a write trigger will recursively fire another write trigger.

It does not.

But feel free to test it.
 
Top