INSERT trigger for inserting record in same table

后端 未结 3 600
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 22:20

I have a trigger that is fire on inserting a new record in table in that i want to insert new record in the same table.
My trigger is :

create or repl         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 22:46

    I'd say that you should look at any way OTHER than triggers to achieve this. As mentioned in the answer from Mark Bobak, the trigger is inserting a row and then for each row inserted by the trigger, that then needs to call the trigger to insert more rows.

    I'd look at either writing a stored procedure to create the insert or just insert via a sub-query rather than by values.

    Triggers can be used to solve simple problems but when solving more complicated problems they will just cause headaches.

    It would be worth reading through the answers to this duplicate question posted by APC and also these this article from Tom Kyte. BTW, the article is also referenced in the duplicate question but the link is now out of date.

提交回复
热议问题