title: Comparing dates with null value in trigger in Oracle 10
body: <p>I am sorry if I am asking a question which was already answered, but I cannot find any answer on it. I am writing a trigger in Oracle 10, where I compare 2 dates, as numbers, but I have a problem, if the second value is null. </p>
  
  <p>I have two tables: <code>Herci</code> (<code>dat_umr_her:date</code>) and <code>filmy</code> (<code>rok_vyd:integer</code>). </p>
  
  <p>The problem is that <code>dat_umr_her</code> is sometimes <code>NULL</code> and then I cannot insert any new Herec because an application error is raised inside the if statement.</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER "XVIKD00"."DATUM_UMRTIA_HEREC" 
    BEFORE INSERT OR UPDATE 
    ON HERCI
    FOR EACH ROW 
  DECLARE 
    l_ROK_VYDANIA filmy.ROK_VYD%TYPE;
  BEGIN 
    SELECT FILMY.ROK_VYD
      INTO l_ROK_VYDANIA 
      FROM FILMY
     WHERE FILMY.ID_FILM = :new.ID_HEREC;
  
    IF( extract( year from :new.dat_umr_her ) &lt; l_ROK_VYDANIA )
    THEN
      RAISE_APPLICATION_ERROR(-2009,'Dátumy nie su v správnom časovom slede'); 
    END IF;
  END;
  </code></pre>