title: Oracle Error: ORA-00923: FROM keyword not found where expected
body: <p>I wrote a trigger on my Oracle db but it showed me this error:</p>
  
  <pre><code>Compilation failed, line 11 (17:21:05) The line numbers associated
  with compilation errors are relative to the first BEGIN statement.
  This only affects the compilation of database triggers. PL/SQL:
  ORA-00923: FROM keyword not found where expectedCompilation failed,
  line 11 (17:21:05) The line numbers associated with compilation errors
  are relative to the first BEGIN statement. This only affects the
  compilation of database triggers. PL/SQL: SQL Statement ignored
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER BEGIN_CALL1 AFTER INSERT ON STATE_CHANGE
  FOR EACH ROW
  WHEN (NEW.ChangeType = 'C')
    DECLARE
      N           NUMBER;
      N_1         NUMBER;
      ID_CELL     NUMBER;
      MC          NUMBER;
      NUM_ATT     NUMBER;
      PHONE_STATE CHAR(6);
      X_0         NUMBER;
      X_1         NUMBER;
      Y_0         NUMBER;
      Y_1         NUMBER;
    BEGIN
      SELECT COUNT(*)
      INTO N
      FROM CELL
      WHERE ((x0 &lt;= :NEW.x AND :NEW.x &lt; x1) AND (y0 &lt;= :NEW.y AND :NEW.y &lt; y1));
      IF N &lt;&gt; 0
      THEN --la cella di appartenenza esiste
        SELECT CellId
        INTO ID_CELL, x0 INTO X_0, y0 INTO Y_0, x1 INTO X_1,y1 INTO Y_1
        FROM CELL
        WHERE ((x0&lt;=:NEW.x AND :NEW.x&lt;x1) AND (y0&lt;=:NEW.y AND :NEW.y&lt;y1));
        SELECT COUNT(*)
        INTO N
        FROM TELEPHONE
        WHERE PhoneNo = :NEW.PhoneNo;
        IF (N &lt;&gt; 0)
        THEN
          SELECT COUNT(*)
          INTO NUM_ATT
          FROM TELEPHONE
          WHERE (x &gt;= X_0 AND x &lt; X_1) AND (y &gt;= Y_0 AND y &lt; Y_1)
                AND PhoneState = 'Active';
          SELECT MaxCalls
          INTO MC
          FROM CELL
          WHERE CellId = ID_CELL;
          IF ((NUM_ATT + 1) &lt;= MC)
          THEN
            UPDATE TELEPHONE
            SET PhoneState = 'Active'
            WHERE PhoneNo = :NEW.PhoneNo;
          ELSE
            SELECT MAX(ExId)
            INTO N
            FROM EXCEPTION_LOG
            WHERE CellId = ID_CELL;
            IF (N IS NULL)
            THEN N := 0;
            END IF;
            INSERT INTO EXCEPTION_LOG (ExId, CellId, ExceptionType)
            VALUES (N + 1, ID_CELL, 'C');
          END IF;
        ELSE
          raise_application_error(-20003, 'Telephone switched off or unknown.');
        END IF;
      ELSE
        raise_application_error(-20001, 'Cell not recognized');
      END IF;
    END;
  </code></pre>
  
  <p>The error should be here (11 lines from BEGIN): </p>
  
  <pre><code>SELECT COUNT(*) INTO N
  FROM TELEPHONE
  WHERE PhoneNo=:NEW.PhoneNo;
  </code></pre>
  
  <p>but I've no idea where is the error. Someone can help me?</p>