title: SQL - Trigger "not in"
body: <p>I'm trying to make a time trigger in the dubbing database. I want to check that character can't be dubbed in the dubbing of the movie in which the character doesn't appear. Here's the PDM: </p>
  
  <p><img src="https://i.stack.imgur.com/MeE6C.jpg" alt="enter image description here"></p>
  
  <p>and CDM </p>
  
  <p><img src="https://i.stack.imgur.com/3JTmC.jpg" alt="enter image description here"></p>
  
  <p>I'm the begginer with SQL but I know that there should be some trigger in the table 'DUBBES'. I tried to make something like this, but i got a message that trigger is invalid: </p>
  
  <pre><code>CREATE OR REPLACE TRIGGER x_character
  BEFORE INSERT OR UPDATE ON dubbes FOR EACH ROW
  DECLARE
  
    IF (  :NEW.CHAR_id_character NOT IN ( SELECT CHAR_id_CHARACTER
                                            FROM APPEARS
                                           WHERE APPEARS.MOV_id_movie = (SELECT dubbing.Mov_id_movie
                                                                           FROM DUBBING
                                                                          WHERE dubbing.id_dubbing = :NEW.dab_id_dubing)))
    THEN
      RAISE_APPLICATION_ERROR(-20000, 'Character is not in this movie.');
    END IF;
  
  END;
  /
  </code></pre>
  
  <p>I would really appreciate any help.
  Many thanks in advance!</p>