title: PLS Error: 00103 Encountered the symbol "EXCEPTION"
body: <p>So, I've created the following procedure:</p>
  
  <pre><code>--First Stored Procedure--
  CREATE OR REPLACE PROCEDURE sp_GetMileageBalance (StartMileage IN NUMBER,EndMileage IN NUMBER, ExpDate IN DATE)
  IS  --Code declaration section--
      --variables to store column values returned from select into
       fPassengerID        VARCHAR2(10);
       pFirst              VARCHAR2(20);
       pLast               VARCHAR2(20);
       fFreqflyernum       NUMBER (10);
       fFreqflyerMileage   NUMBER (7);
       fMileagebalance     NUMBER (7);
       fMileageExpDate     DATE;
       MileageExpDate      DATE;
       MileageStart        NUMBER (7);
       MileageEnd          NUMBER (7);
       MileageBalance      NUMBER (7);
  
       --Declare Cursor
                CURSOR cur_FreqFlyer IS
       --Query cursor will point to results         
  SELECT F.FPASSENGERID, P.First, P.Last, F.FREQFLYERNUM, F.FREQFLYERMILEAGE, F.MILEAGEBALANCE, F.MILEAGEEXPDATE
  INTO  fPassengerID, pFirst,pLast,fFreqflyernum,fFreqflyerMileage,fMileagebalance,fMileageExpDate
  FROM FREQUENT_FLYER F
  INNER JOIN PASSENGER P
  ON F.FPassengerID = P.PassengerID
  WHERE F.MileageBalance &gt;= StartMileage AND F.MILEAGEBALANCE &lt;= EndMileage
  AND MileageExpDate &gt; ExpDate;
  
  
      --Start Execution section--
  BEGIN 
       --Open Cursor
       OPEN cur_FreqFlyer; --  open cursor for use   
       --loop to display each record returned by cursor 
       --Use PL/SQL language control or loop to display each record pointed by cursor 
     LOOP
          --Fetch cursor data
          FETCH cur_FreqFlyer INTO fPassengerID,pFirst,pLast,fFreqflyernum,fFreqflyerMileage,
          fMileageBalance,fMileageExpDate;
          EXIT WHEN cur_FreqFlyer%NOTFOUND;
          --Display each record
          --Displaying the results
  
  
  DBMS_OUTPUT.PUT_LINE ('CUSTOMER INFORMATION: ');
  DBMS_OUTPUT.PUT_LINE (' ');
  DBMS_OUTPUT.PUT_LINE ('The Frequent Flyer PassengerID is:  ' ||fPassengerID);
  DBMS_OUTPUT.PUT_LINE ('First Name of passenger is:  ' ||pFirst);
  DBMS_OUTPUT.PUT_LINE ('Last Name of passenger is:  ' ||pLast);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer number of passenger is: ' ||fFreqflyernum);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer Mileage of Passenger is:  ' ||fFreqflyerMileage);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer Balance of passenger is:  ' ||fMileageBalance );
  DBMS_OUTPUT.PUT_LINE ('Mileage expiration date of passenger is:  ' ||fMileageExpDate);
  DBMS_OUTPUT.PUT_LINE (' ');
  
  END LOOP;
  
          CLOSE cur_FreqFlyer; --close cursor
  
          END sp_GetMileageBalance;
  </code></pre>
  
  <p>When I ran that, it worked as expected. When I ran the stored procedure:</p>
  
  <pre><code>SET SERVEROUTPUT ON
  
          EXECUTE sp_GetMileageBalance (10000,20000,'01-OCT-17');
  </code></pre>
  
  <p>I Got my results:</p>
  
  <pre><code>CUSTOMER INFORMATION: 
  
  The Frequent Flyer PassengerID is:  KL87DF34DS
  First Name of passenger is:  Michelle
  Last Name of passenger is:  Mullington
  Frequent Flyer number of passenger is: 9374392018
  Frequent Flyer Mileage of Passenger is:  400
  Frequent Flyer Balance of passenger is:  15000
  Mileage expiration date of passenger is:  19-DEC-20
  
  &gt;PL/SQL procedure successfully completed.
  </code></pre>
  
  <p>However, when I tried to put an exception:</p>
  
  <pre><code>EXCEPTION
      WHEN no_data_found THEN
       -- do something
       dbms_output.put_line('Results not found.Try again ');
  </code></pre>
  
  <p>It gave me this error: </p>
  
  <p>LINE/COL ERROR</p>
  
  <hr>
  
  <p>54/2     PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
           ( begin case declare end exit for goto if loop mod null
           pragma raise return select update while with 
             &lt;&lt;
           continue close current delete fetch lock insert open rollback
           savepoint set sql execute commit forall merge pipe purge</p>
  
  <p>62/5     PLS-00103: Encountered the symbol "CLOSE" when expecting one of the following:
           end not pragma final instantiable order overriding static
           member constructor map</p>
  
  <p>Don't know why it spiting this back at me.</p>
  
  <p>This is how I placed it in my code:</p>
  
  <pre><code>--First Stored Procedure--
  CREATE OR REPLACE PROCEDURE sp_GetMileageBalance (StartMileage IN NUMBER,EndMileage IN NUMBER, ExpDate IN DATE)
  IS  --Code declaration section--
      --variables to store column values returned from select into
       fPassengerID        VARCHAR2(10);
       pFirst              VARCHAR2(20);
       pLast               VARCHAR2(20);
       fFreqflyernum       NUMBER (10);
       fFreqflyerMileage   NUMBER (7);
       fMileagebalance     NUMBER (7);
       fMileageExpDate     DATE;
       MileageExpDate      DATE;
       MileageStart        NUMBER (7);
       MileageEnd          NUMBER (7);
       MileageBalance      NUMBER (7);
  
       --Declare Cursor
                CURSOR cur_FreqFlyer IS
       --Query cursor will point to results         
  SELECT F.FPASSENGERID, P.First, P.Last, F.FREQFLYERNUM, F.FREQFLYERMILEAGE, F.MILEAGEBALANCE, F.MILEAGEEXPDATE
  INTO  fPassengerID, pFirst,pLast,fFreqflyernum,fFreqflyerMileage,fMileagebalance,fMileageExpDate
  FROM FREQUENT_FLYER F
  INNER JOIN PASSENGER P
  ON F.FPassengerID = P.PassengerID
  WHERE F.MileageBalance &gt;= StartMileage AND F.MILEAGEBALANCE &lt;= EndMileage
  AND MileageExpDate &gt; ExpDate;
  
  
      --Start Execution section--
  BEGIN 
       --Open Cursor
       OPEN cur_FreqFlyer; --  open cursor for use   
       --loop to display each record returned by cursor 
       --Use PL/SQL language control or loop to display each record pointed by cursor 
     LOOP
          --Fetch cursor data
          FETCH cur_FreqFlyer INTO fPassengerID,pFirst,pLast,fFreqflyernum,fFreqflyerMileage,
          fMileageBalance,fMileageExpDate;
          EXIT WHEN cur_FreqFlyer%NOTFOUND;
          --Display each record
          --Displaying the results
  
  
  DBMS_OUTPUT.PUT_LINE ('CUSTOMER INFORMATION: ');
  DBMS_OUTPUT.PUT_LINE (' ');
  DBMS_OUTPUT.PUT_LINE ('The Frequent Flyer PassengerID is:  ' ||fPassengerID);
  DBMS_OUTPUT.PUT_LINE ('First Name of passenger is:  ' ||pFirst);
  DBMS_OUTPUT.PUT_LINE ('Last Name of passenger is:  ' ||pLast);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer number of passenger is: ' ||fFreqflyernum);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer Mileage of Passenger is:  ' ||fFreqflyerMileage);
  DBMS_OUTPUT.PUT_LINE ('Frequent Flyer Balance of passenger is:  ' ||fMileageBalance );
  DBMS_OUTPUT.PUT_LINE ('Mileage expiration date of passenger is:  ' ||fMileageExpDate);
  DBMS_OUTPUT.PUT_LINE (' ');
  
   EXCEPTION
      WHEN no_data_found THEN
       -- do something
       dbms_output.put_line('Results not found.Try again ');
  
  
  END LOOP;
  
      CLOSE cur_FreqFlyer; --close cursor
  
  END sp_GetMileageBalance;
  </code></pre>