title: Creating trigger which throws an exception on insert
body: <p>Hello fellow programmers and happy new year to you all!</p>
  
  <p>I have few university tasks for winter break and one of them is to create trigger on table: </p>
  
  <pre><code>PERSON(ID, Name, Surname, Age);
  </code></pre>
  
  <p>Trigger is supposed to inform user when they have inserted row with invalid ID. Vadility criteria is that ID is 11 digits long. </p>
  
  <p>I tried to write solution like this: </p>
  
  <pre><code>CREATE OR REPLACE TRIGGER person_id_trigg
  AFTER INSERT
  ON person
  DECLARE
    idNew VARCHAR(50);
    lengthException EXCEPTION;
  BEGIN
    SELECT id INTO idNew FROM INSERTED;
    IF LENGTH(idNew) &lt;&gt; 11 THEN
    RAISE lengthException;
    END IF;
    EXCEPTION
    WHEN lengthException THEN
    dbms_output.put_line('ID for new person is INVALID. It must be 11 digits long!'); 
  END;
  </code></pre>
  
  <p>Then I realized that INSERTED exists only in sqlserver and not in oracle. </p>
  
  <p>What would you suggest I could do to fix that? </p>
  
  <p>Thanks in advance!</p>