title: PL/SQL code not inserting records into table
body: <p>BACKGROUND: i'm using oracle SQLDeveloper, I have the tables:</p>
  
  <p><strong>TUTPRAC</strong>: CLASSID (PK), UNITCODE, STAFFNO, CLASSDAY, CLASSTIME, CLASSTYPE, ROOMNUM</p>
  
  <p><strong>UNITSTREAM</strong>: STREAMID (PK), UNITCODE, STAFFNO, DAY, TIME, LOCATION</p>
  
  <p>PROBLEM: My current code no matter what i try to enter using the procedure does not enter a record even if the record is completely unique in terms of day, time and room.</p>
  
  <p>What i am trying to do with the procedure is to check if there is any class already occupying the day/time/room of the record i'm trying to enter using the procedure.</p>
  
  <p>For a record to be added successfully = The unit (e.g COMP111 (UNITCODE)) cannot have any classes in the same day (regardless of time or venue). It also cannot be assigned the same room as a another unit to prevent 2 classes being booked into the same classroom (e.g. SCIE112). And finally the unit cannot have a class at the same as that units lecture (lecture details are stored in UNITSTREAM table).</p>
  
  <p>TUTPRACS contains the records for both tutorials and practicals while UNITSTREAM containts the records for streams (Lectures).</p>
  
  <p>I'm quite new to PL/SQL so any help would be greatly appreciated. My code so far:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE OPEN_CLASS(
             p_class IN TUTPRAC.CLASSID%TYPE,
             p_unitc IN TUTPRAC.UNITCODE%TYPE,
             p_classd IN TUTPRAC.CLASS_DAY%TYPE,
             p_classt IN TUTPRAC.CLASS_TIME%TYPE,
             p_classtp IN TUTPRAC.CLASS_TYPE%TYPE,
             p_roomnm IN TUTPRAC.ROOMNUM%TYPE)
      IS
     x NUMBER:=0;
     y NUMBER:=0;  
  BEGIN
  
      -- checks
      SELECT nvl((SELECT 1 FROM TUTPRAC WHERE CLASS_DAY = p_classd and CLASS_TIME = p_classt and CLASS_TYPE = p_classtp and ROOMNUM = p_roomnm) , 0) INTO x FROM dual;
      SELECT nvl((SELECT 1 FROM UNITSTREAM WHERE UNITCODE = p_unitc and DAY = p_classd and TIME = p_classt and LOCATION = p_roomnm) , 0) INTO y FROM dual;
  
      -- insert
      IF (x = 1 and y = 1) THEN
          INSERT INTO TUTPRAC ("CLASSID", "UNITCODE", "CLASS_DAY", "CLASS_TIME", "CLASS_TYPE", "ROOMNUM") 
        VALUES (p_class, p_unitc, p_classd, p_classt, p_classtp, p_roomnm);
      END IF;
  END OPEN_CLASS;
  </code></pre>