Mutating table on Oracle SQL trigger

后端 未结 2 1137
一整个雨季
一整个雨季 2021-01-29 06:42

I\'m trying to do a trigger but I get a mutating table error. The SQL code is something like this:

CREATE OR REPLACE TRIGGER CHK_Apartado_D
BEFORE INSERT OR UPDA         


        
相关标签:
2条回答
  • 2021-01-29 07:29

    Your trigger fires on update or insert of CONTRACTS and then tries to update CONTRACTS, which fires the trigger.... See the problem?

    You need to work out the enddate and then actually do the insert / update.

    0 讨论(0)
  • 2021-01-29 07:37

    A common solution is Using Compound Triggers to Avoid Mutating-Table Error.

    Better still, don't attempt to use triggers to implement complex business logic. Instead, build an API package with a procedure insert_contract that implements the business rules, and ensure (via privileges) that users call that API rather than inserting directly into the table. Triggers can get very messy, very quickly.

    0 讨论(0)
提交回复
热议问题