开发者

Is an INSERT trigger recursive, or cause an infinite loop?

开发者 https://www.devze.com 2023-03-07 19:55 出处:网络
I have an INSERT trigger on table. When a row is inserted in table, the INSERT trigger is fired. The trigger\'s behaviour is such that it will insert another row into the same table.

I have an INSERT trigger on table. When a row is inserted in table, the INSERT trigger is fired.

The trigger's behaviour is such that it will insert another row into the same table.

What would be the result of the INSERT statement?

Does this INSERT result in an infinite loop, or just the expected 2 inserts开发者_如何学运维?


This is a setting in SQL- see the CREATE TRIGGER msdn page, specifically the section on Recursive Triggers. The setting you need to look into is RECURSIVE_TRIGGERS, if this is false, a trigger on Table1 will not trigger another insert into Table1. If you do allow recursive triggers, the limit is 32 levels deep.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号