Skip to content
Advertisement

How to implement AFTER INSERT Trigger in Oracle PL/SQL?

I am trying to implement after insert trigger in PLSQL.
The goal is to check if there are multiple (>1) rows having specific status for each client.
If so I’d like to rise an exception and roll the insertion back.

I am struggling with implementing warning-free query, which causes error during insertion.
How could I manage this?
Here is my implemented trigger which I guess needs some changes.

Here is the table itself:

Advertisement

Answer

Use a Statement Level Trigger, rather than a Row Level by removing FOR EACH ROW, and converting to your code as below :

where

  • the SELECT statement need to be removed from IF .. THEN conditional
  • Most probably, the mutating table error would raise for Row Level Trigger case

Demo

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement