Compilation error in the following code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekgvyas
    New Member
    • May 2007
    • 2

    Compilation error in the following code

    Hi,
    can somebody tell me what is wrong with the following stored procedure code..

    SQL> CREATE OR REPLACE PROCEDURE DEBIT_ACCOUNT(A CCT_ID IN NUMBER, DEBIT_AMOUNT OUT NUMBER)
    2 IS
    3 OLD_BAL_AMT NUMBER;
    4 NEW_BAL_AMT NUMBER;
    5 WITHDRAWN_AMT NUMBER;
    6 BEGIN
    7 SELECT BAL_AMT INTO OLD_BAL_AMT FROM ACCOUNTS
    8 WHERE ACC_NO = ACCT_ID;
    9 NEW_BAL_AMT := OLD_BAL_AMT - DEBIT_AMOUNT;
    10 IF NEW_BAL_AMT < 0 THEN
    11 RAISE E_WITHDRAWN;
    12 ELSE
    13 UPDATE ACCOUNTS SET BAL_AMT = NEW_BAL_AMT
    14 WHERE ACC_NO = ACCT_ID;
    15 END IF;
    16 COMMIT;
    17 EXCEPTION
    18 WHEN E_WITHDRAWN THEN
    19 -- HANDLE THE ERROR
    20 END DEBIT_ACCOUNT;
    21 /

    Warning: Procedure created with compilation errors.

    SQL> show error
    Errors for PROCEDURE DEBIT_ACCOUNT:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    20/1 PLS-00103: Encountered the symbol "END" when expecting one of the
    following:
    begin declare exit for goto if loop mod null pragma raise
    return select update while <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall
    <a single-quoted SQL string>

    Warm Regards,
    Abhishek Vyas
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    The error message is telling you what is wrong with it.

    20/1 PLS-00103: Encountered the symbol "END" when expecting one of the
    following:
    begin declare exit for goto if loop mod null pragma raise
    return select update while <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall
    <a single-quoted SQL string>

    It's telling you that where you have "END" there should be something else...and it even tells you what else you can put there

    Comment

    Working...