title: PL/SQL Trigger to prevent insertion
body: <p>I need to write trigger in PL/SQL. I want insertion to be prevented when the condition is true.</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER SafeRent AFTER INSERT ON Rent
  FOR EACH ROW 
  DECLARE
  BEGIN
      IF :NEW.id_status IN (1,2) THEN
          DELETE FROM Rent WHERE id_rent = :NEW.id_rent;
      END IF;
  END;
  </code></pre>
  
  <p>Explonation to the code: if id_status equals 1 or 2 I want insertion NOT to be done.</p>
  
  <p>This is the trigger I wrote. It deletes (I suppose so, I have not tested it) the record after insertion if the condition is true.</p>
  
  <p>Is there any way to prevent it before insertion?</p>
  
  <p>I was thinking about rising exception in 'BEFORE INSERT' type trigger, is it a good solution?</p>
  
  <p>PS: It must be trigger, I know it can be implemeted as Check constraints.</p>