title: PL/SQL Procedure Syntax
body: <p>So i'm having a little trouble with some PL SQL statements. Essentially i'm trying to create a procedure that will check that when a new tuple is inserted, the procedure checks that there isn't another contract for the same person within the same dates ie. the dates of the new contract don't overlap the dates of the other.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE dateOrder 
  (name IN VARCHAR2, start IN DATE, end IN DATE)
  IS 
      x number;
      y number;
  
  BEGIN
      CREATE OR REPLACE VIEW PersonContracts AS
      SELECT * FROM ContractInfo WHERE HasContract=name;
  
      SELECT COUNT(*) INTO x FROM PersonContracts
      WHERE start BETWEEN date_from AND date_to;
  
      SELECT COUNT(*) INTO y from PersonContracts
      WHERE end BETWEEN date_from AND date_to;
      IF x &gt; 0 THEN
          dbms_output.put_line("overlaps.");
      END IF;
  
      IF Y &gt; 0 THEN
          dbms_output.put_line("overlaps.");
      END IF;
  
  END dateOrder;
  /
  
  BEGIN
      dateOrder("John Smith", "08-oct-2014", "12-oct-2014");
  END;
  </code></pre>
  
  <p>I have tried it with or without the view but i would prefer to keep the view if possible. I'm only new at PL!</p>