title: Oracle SQL Trigger Syntax
body: <p>I am trying to create a trigger that checks if the faculty member to be added to the assigned table will is already on the qualified table for a specified class. Perhaps this is a tedious method. Nevertheless, I'd still like to know what I'm doing wrong. The following is my code with created the created tables and the trigger being the last part of the code:</p>
  
  <p>CODE:</p>
  
  <pre><code>CREATE TABLE Faculty (
    FId varchar(10),
    FName varchar(20),
    CONSTRAINT Faculty_ID_pk PRIMARY KEY(FId)
  );
  
  CREATE TABLE Course (
    CId varchar(10),
    CName varchar(20),
    CONSTRAINT Course_ID_pk PRIMARY KEY(CId)
  );
  
  CREATE TABLE Qualify (
    QDate DATE,
    FId varchar(10),
    CId varchar(10),
    CONSTRAINT Qualifying_date CHECK(QDate &gt;= TO_DATE('2020-08-24', 'YYYY-MM-DD')),
    CONSTRAINT Qualify_FID_fk FOREIGN KEY(FId) REFERENCES Faculty(FId),
    CONSTRAINT Qualify_CID_fk FOREIGN KEY(CId) REFERENCES Course(CId)
  );
  
  CREATE TABLE Assign (
    ADate DATE,
    FId varchar(10),
    CId varchar(10),
    CONSTRAINT Qualifying_check CHECK(ADate &gt; TO_DATE('2020-08-24', 'YYYY-MM-DD')),
    CONSTRAINT Assign_FID_fk FOREIGN KEY(FId) REFERENCES Faculty(FId),
    CONSTRAINT Assign_CID_fk FOREIGN KEY(CId) REFERENCES Course(CId)
  );
  
  
  
  CREATE OR REPLACE TRIGGER Check_If_Qualified
     BEFORE INSERT ON Assign
     FOR EACH ROW
  DECLARE
     v_facNum number;
  BEGIN
     SELECT f.FId
        into v_facNum
        from Faculty f
        where f.facnum = :new.fid;
  END;
  </code></pre>
  
  <p>However, I keep receiving an error saying:</p>
  
  <p>Error at line 7: PLS-00225: subprogram or cursor 'F' reference is out of scope</p>
  
  <ol start="5">
  <li>v_facNum number;</li>
  <li>BEGIN</li>
  <li>SELECT f.FId</li>
  <li>into v_facNum</li>
  <li>from Faculty f</li>
  </ol>
  
  <p>Does anyone know what could be wrong?</p>