Subject [firebird-support] Re: Trigger nesting level
Author Svein Erling Tysvaer
Why not add a field to the table, say NestedLevel and in your trigger
have something like

if (new.NestedLevel < 100) then
begin
insert into MyTable(NestedLevel, ...)
values (New.NestedLevel + 1, ...)

This way, it is simple to control the recursion.

HTH,
Set

lacakus wrote:
>>> I need detect and stop infinite recursive calling of triggers or
> SPs ?
>> Firebird does it for you. It will throw an error as soon as you reach
>> about 1000 nested calls.
>>
> Thanks for reply ...
> Suppose situation when I insert row in table "T", which has insert
> trigger in which is conditional insert into "T" ...
>
> 1. insert into T ...
> 2. trigger is fired ... and inside trigger is again insert into T ...
> (so step 2 may be executed multiple times)
>
> If infinite loop occurs and FB stops with error at approx. 1000 nesting
> levels ... all changes into table T (including step 1. - original SQL
> insert statement) will be rolled back ?
>
> TIA
> -Laco.