Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8294427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:12:47+00:00 2026-06-08T14:12:47+00:00

Oracle SP not compiling I am expierenced at MS SQL but taking a class

  • 0

Oracle SP not compiling

I am expierenced at MS SQL but taking a class in Oracle and for the life of me cannot figure out why this script for a stored Procedure will not work. I am getting an error in the variable declaration section at the first Exception variable. here is the error message:

 PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
 in out <an identifier> <a double-quoted delimited-identifier> LONG_ double ref char
 time timestamp interval date binary national character nchar

The code

CREATE or REPLACE Procedure Movie_Rental_SP
(
Mv_ID IN Number,
Mem_ID IN Number,
Pay_ID IN Number,
Mv_Chk Number,
Mem_Chk Number,
Pay_Chk Number,
Qty_Chk Number,
--> next line is where the error points
      UnKnown_Mv Exception,
UnKnown_Mem Exception,
UnKnown_Pay Exception,
UnAvail_Mv Exception    )

IS

BEGIN
SELECT COUNT(Movie_ID) INTO Mv_Chk FROM MM_Movie WHERE Movie_ID = Mv_ID; 
SELECT COUNT(Member_ID) INTO Mem_Chk FROM MM_Member WHERE Member_ID = Mem_ID;
SELECT COUNT(Payment_Methods_ID) INTO Pay_Chk FROM MM_Pay_Type WHERE Payment_Methods_ID = Pay_ID;
SELECT Movie_Qty INTO Qty_Chk FROM MM_Movie WHERE Movie_ID = Mv_ID;

IF       Mv_Chk = 0 THEN RAISE UnKnown_Mv;
ELSE IF Mem_Chk = 0 THEN RAISE UnKnown_Mem;
ELSE IF Pay_Chk = 0 THEN RAISE UnKnown_Pay;
ELSE    Qty_Chk = 0 THEN RAISE UnAvail_Mv;
END IF; 

    DECLARE New_ID NUMBER;
    BEGIN
        SELECT Max(Rental_ID)+1 INTO New_ID FROM MM_Rental;
        EXCEPTION WHEN NO_DATA_FOUND THEN
            New_ID := 1;
            DBMS_OUTPUT.PUT_LINE ('There are no exsisting Rental IDs, ID set to 1');
    END;

INSERT INTO MM_Rental VALUES (New_ID,Mem_ID,Mv_ID,Sysdate,Null,Pay_ID);
UPDATE MM_Movie SET Movie_Qty = Movie_Qty - 1 WHERE Movie_ID = Mv_ID;

EXCEPTION 
    WHEN UnKnown_Mv THEN 
        RAISE_APPLICATION_ERROR(-20001,'There is no movie with Movie ID of: '||Mv_ID||' Transaction cancelled.');
    WHEN UnKnown_Mem THEN 
        RAISE_APPLICATION_ERROR(-20002,'No member exists with member ID: '||Mem_ID||' Transaction cancelled.');
    WHEN UnKnown_Pay THEN
        RAISE_APPLICATION_ERROR(-20003,'No payment type for: '||Pay_ID||' Transaction cancelled.');
    WHEN UnAvail_Mv THEN
        RAISE_APPLICATION_ERROR(-20004,'No movies available for: '||Mv_ID||' Transaction cancelled.');
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE ('Error number: '||sqlcode);
        DBMS_OUTPUT.PUT_LINE ('Error message: '||sqlerrm);
        DBMS_OUTPUT.PUT_LINE('Unanticipated error.  Contact your system administrator.');
END;
/

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:12:49+00:00Added an answer on June 8, 2026 at 2:12 pm

    My assumption is that after the three IN parameters, your intention is to declare everything else as a local variable, not as parameters to the procedure. It wouldn’t make sense to pass exceptions to a procedure. Your ‘ELSE IFalso needs to beELSIF`.

    CREATE or REPLACE Procedure Movie_Rental_SP
    (
      Mv_ID IN Number,
      Mem_ID IN Number,
      Pay_ID IN Number
    )
    AS
      Mv_Chk Number;
      Mem_Chk Number;
      Pay_Chk Number;
      Qty_Chk Number;
      UnKnown_Mv Exception;
      UnKnown_Mem Exception;
      UnKnown_Pay Exception;
      UnAvail_Mv Exception;  
    BEGIN
      SELECT COUNT(Movie_ID) INTO Mv_Chk FROM MM_Movie WHERE Movie_ID = Mv_ID; 
      SELECT COUNT(Member_ID) INTO Mem_Chk FROM MM_Member WHERE Member_ID = Mem_ID;
      SELECT COUNT(Payment_Methods_ID) INTO Pay_Chk FROM MM_Pay_Type WHERE Payment_Methods_ID = Pay_ID;
      SELECT Movie_Qty INTO Qty_Chk FROM MM_Movie WHERE Movie_ID = Mv_ID;
    
      IF    Mv_Chk = 0 THEN RAISE UnKnown_Mv;
      ELSIF Mem_Chk = 0 THEN RAISE UnKnown_Mem;
      ELSIF Pay_Chk = 0 THEN RAISE UnKnown_Pay;
      ELSE  Qty_Chk = 0 THEN RAISE UnAvail_Mv;
      END IF; 
    
      DECLARE 
        New_ID NUMBER;
      BEGIN
        SELECT Max(Rental_ID)+1 INTO New_ID FROM MM_Rental;
      EXCEPTION WHEN NO_DATA_FOUND THEN
         New_ID := 1;
         DBMS_OUTPUT.PUT_LINE ('There are no exsisting Rental IDs, ID set to 1');
      END;
    
      INSERT INTO MM_Rental VALUES (New_ID,Mem_ID,Mv_ID,Sysdate,Null,Pay_ID);
      UPDATE MM_Movie SET Movie_Qty = Movie_Qty - 1 WHERE Movie_ID = Mv_ID;
    EXCEPTION 
      WHEN UnKnown_Mv THEN 
         RAISE_APPLICATION_ERROR(-20001,'There is no movie with Movie ID of: '||Mv_ID||' Transaction cancelled.');
      WHEN UnKnown_Mem THEN 
          RAISE_APPLICATION_ERROR(-20002,'No member exists with member ID: '||Mem_ID||' Transaction cancelled.');
      WHEN UnKnown_Pay THEN
          RAISE_APPLICATION_ERROR(-20003,'No payment type for: '||Pay_ID||' Transaction cancelled.');
      WHEN UnAvail_Mv THEN
          RAISE_APPLICATION_ERROR(-20004,'No movies available for: '||Mv_ID||' Transaction cancelled.');
      WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE ('Error number: '||sqlcode);
          DBMS_OUTPUT.PUT_LINE ('Error message: '||sqlerrm);
          DBMS_OUTPUT.PUT_LINE('Unanticipated error.  Contact your system administrator.');
    END;
    /
    

    As a general principle, a WHEN OTHERS exception handler that does not re-raise the exception is almost certainly an error. Writing data to dbms_output does not in any way guarantee that the data will be seen by anyone or persisted anywhere. So, for example

      WHEN OTHERS THEN
          DBMS_OUTPUT.PUT_LINE ('Error number: '||sqlcode);
          DBMS_OUTPUT.PUT_LINE ('Error message: '||sqlerrm);
          DBMS_OUTPUT.PUT_LINE('Unanticipated error.  Contact your system administrator.');
          RAISE;
    

    will re-throw whatever exception was previously raised. Of course, you’d get the same behavior if you simply didn’t catch exceptions that you can’t handle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If the database is not Oracle, it is MS SQl 2008. My task: if
I'm using Oracle SQL Developer to query an Oracle DB (not sure which version
I am trying to execute the following query in oracle but not able to
I recently was reading about Oracle Index Organized Tables (IOTs) but am not sure
My application accesses an Oracle database through Qt's QSqlDatabase class. I'm compiling Qt as
this one isn't a dev question but silly tech quesiton... I had installed oracle
Based on example found here but I guess I'm not understanding it. This works
I'm getting this err msg: System.ArgumentException was unhandled Message=Value with type Devart.Data.Oracle.OracleParameter not supported.
I'm using oracle 11 (not sure about the exact version, but since LISTAGG doesn't
I just stumbled upon something in ORACLE SQL (not sure if it's in others),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.