Results 1 to 4 of 4

Thread: PL/SQL error :

  1. #1
    Join Date
    Jan 2010
    Posts
    64

    Question Unanswered: PL/SQL error :

    Hi ALL,

    I am getting error when i am running the sql mentioned below.

    ================================================== =====
    DECLARE
    stapol number(3);
    stapol := &1;

    BEGIN




    CASE stapol
    WHEN 500 then dbms_output.put_line('Live Status')
    WHEN 585 then dbms_output.put_line('Paid Up Status')
    WHEN 817 then dbms_output.put_line('Terminated')
    ELSE dbms_output.put_line('Don't Know')
    END;
    /
    ==================================================
    Enter value for 1: 500
    old 6: stapol := &1;
    new 6: stapol := 500;
    ERROR:
    ORA-01756: quoted string not properly terminated
    ==================================================

    Please Advice !!!

    Subhotech
    Last edited by subhotech; 06-14-10 at 07:25. Reason: typo

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    The error is here because of Don't - you can't use a single quote because it terminates a string. Therefore, either say Do not or Don''t (two consecutive single quotes).

    However, you'll find other errors too. "stapol := &1;" should be behind the BEGIN. CASE requires END, as well as BEGIN (so there's one missing).

  3. #3
    Join Date
    Jan 2010
    Posts
    64

    Not working

    I have modified the code but still getting errors

    DECLARE
    stapol number(3);
    BEGIN

    stapol := &1;

    dbms_output.put_line(stapol);

    CASE stapol
    WHEN 500 THEN dbms_output.put_line('Live Status')
    ELSE dbms_output.put_line('Dont Know')
    END;

    END;
    /

  4. #4
    Join Date
    Mar 2007
    Posts
    623
    It would be nice if you posted the error message as well.
    ERROR at line 11:
    ORA-06550: line 11, column 1:
    PLS-00103: Encountered the symbol "ELSE" when expecting one of the following: := . ( % ;
    The symbol ";" was substituted for "ELSE" to continue.
    ORA-06550: line 12, column 1:
    PLS-00103: Encountered the symbol "END" when expecting one of the following: := . ( % ;
    As the problem is in the CASE statement, it would be nice to familiarize with its correct syntax. It is described in PL/SQL User's Guide and Reference, available with other Oracle documentation books e.g. online on Search and Download Oracle Database, Application Server, and Collaboration Suite Documentation
    Evidently, it misses semicolon (;) after its statements; most probably it will also require END CASE instead of END in its end.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •