Update same table after Insert trigger

前端 未结 2 1965
孤街浪徒
孤街浪徒 2021-01-24 08:50

I am working on a product in which I have to send SMS to concerned person when someone waits for more than 15 minutes for being served.

For that I have written a procedu

相关标签:
2条回答
  • 2021-01-24 09:05

    You cannot update the same table in Row-Level AFTER Trigger.
    Change your Row-Level AFTER INSERT trigger to row-level BFEORE INSERT trigger.

    But you UPDATE stmt inside the trigger will not effect the new record being inserted.

    Wonder how it can be done, this is tricky.

    0 讨论(0)
  • 2021-01-24 09:09

    I don't think that UPDATE is allowed on SOME_TABLE as it is currently mutating.

    Why not place it right after the INSERT statement which fired the trigger in the first place?.

    INSERT INTO SOME_TABLE ...
    update Some_Table set status = 'Y' where id = (select max(id) id  from Some_Table where status = 'N'); --Update Table that SMS has been sent
    

    I guess this would be the right approach considering you aren't doing anything row specific in that UPDATE.

    As I mentioned in the comment, Is there any particular use for this last statement in the AFTER INSERT trigger? It does have meaning in the BEFORE INSERT trigger.

    select 'Y' into :new.status from dual;
    
    0 讨论(0)
提交回复
热议问题