Results 1 to 6 of 6

Thread: whats wrong??

  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Unanswered: whats wrong??

    hi

    when i compile the simple code below :-

    declare
    a number;
    b number;
    c number;
    begin
    a:=&a;
    b:=&b;
    c:= a+b;
    dbms_output.put_line('the sum is' || c);
    end;


    it gives an error
    ORA-06550: line 6, column 4:
    PLS-00103: Encountered the symbol "&" when expecting one of the following...

    can you please locate whats wrong here

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if its an Oracle question then you are more likely to get an answer if you ask the question in the Oracle forum
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    You should provide some more information (for example, Oracle version; where did you run this code (SQL*Plus?); etc.). Because, it kind of works for me (on 10.2.0.3).
    Code:
    SQL> declare
      2   a number;
      3   b number;
      4   c number;
      5   begin
      6   a:=&a;
      7   b:=&b;
      8   c:= a+b;
      9   dbms_output.put_line('the sum is' || c);
     10   end;
     11  /
    Enter value for a: 1
    Enter value for b: 2
    the sum is3
    
    PL/SQL procedure successfully completed.
    
    SQL>
    P.S. By the way, you could have done it simpler:
    Code:
    SQL> begin
      2    dbms_output.put_line('the sum is ' || to_char(&a + &b));
      3  end;
      4  /
    Enter value for a: 4
    Enter value for b: 5
    the sum is 9
    
    PL/SQL procedure successfully completed.
    
    SQL>

  4. #4
    Join Date
    Mar 2012
    Posts
    2
    I am running it on oracle 10g express edition. it seems to have a problem with the '&' operator. So, even the alternative suggested by you is not working bcz of the same '&' problem.

    However, the following queries are working if i replace '&a' by ':a'.it brings up a pop up asking to enter the bind variables and the result is displayed, though the query takes lot of time to run. and i dont know if its th right way to do,i was just trying.

  5. #5
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by nee_123 View Post
    I am running it on oracle 10g express edition. it seems to have a problem with the '&' operator. So, even the alternative suggested by you is not working bcz of the same '&' problem.
    With "running on oracle 10g express edition" I assume you mean "I'm running it in the HTML/Browser GUI of the express edition", because "10g express edition" is the identification of the Oracle database server software, not the client application that enables you to run interactive SQL statements.

    The HTML GUI of the express edition does not support replacement parameters.

    You need to run it using SQL*Plus.

  6. #6
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    You are not using sqlplus. The & replacement variable is ONLY in sqlplus. the colon works with something like toad.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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