Z cyklu #absurdyCorpo
Z dokumentacji oracle można wyczytać:
Using Compound Triggers to Avoid Mutating-Table Error
You can use compound triggers to avoid the mutating-table error (ORA-04091) described in Trigger Restrictions on Mutating Tables.Scenario: A business rule states that an employee's salary increase must not exceed 10% of the average salary for the employee's department. This rule must be enforced by a trigger.
Solution: Define a compound trigger on updates of the table hr.employees, as in Example 9-4. The state variables are initialized each time the trigger fires (even when the triggering statement is interrupted and restarted).
No więc w firmie gdzie pracuję jeden z triggerów mutował. Ktoś sobie doczytał, że jest coś takiego jak compound przerobił triggera i problemu nie ma ... no ale nie uwzględnił tego, że trigger na tabeliA robi insert do tabeliB, następnie uruchamiany jest pakiet, który robi update na tabeliB, trigger na tabeliB (compound) odpala inny pakiet gdzie jest select z tabeliA i uwaga ...:
Sprawdzenie dla klienta : xxx nieudane z powodu bledu ORA-04091: tabela xxx ulega mutacji, wyzwalacz/funkcja może tego nie widzieć
Tak to jest robić logikę na triggerach ...
@Miang: lepiej na pakiecie niż triggerze ... tam gdzie mogę wystawiam pakiet z execute dla usera i robi tylko to co mu pozwolę, a nie chamskie DML z ORM ... a potem masz 100 aplikacji, które tak działają i jak trzeba coś dorobić/zmienić to wszyscy krzyczą że nie da rady 100 aplikacji zgrać w jednym czasie to zrób na bazie i jeb triggerek ...
Złe zaprojektowanie i myślenie krótkoterminowe z utrzymaniem projektu. Do tego pewnie osoba która to tworzyła już nie pracuje więc wiedza domenowa wyparowała. Klasyczne firmy IT.
to lepiej na frontendzie? ;)