2

Code:

DECLARE
 N NUMBER :=&N;
BEGIN
 DBMS_OUTPUT.PUT_LINE(N);
END;

Error:

ORA-06550: line 2, column 12: PLS-00103: Encountered the symbol "&" when expecting one of the following:

( - + case mod new not null continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe

3
  • May I know the IDE you are working with? Commented Feb 17, 2016 at 3:53
  • oracle 10g sql command Commented Feb 17, 2016 at 3:59
  • Did you try set define on; Commented Feb 17, 2016 at 4:37

1 Answer 1

3

You need to do:

SET DEFINE ON

I think you are using GUI client like SQL Developer, and you do not have define on. & is used for a substitution variable.

In SQL Developer:

SET serveroutput ON
SET define OFF
DECLARE
  N NUMBER :=&N;
BEGIN
  DBMS_OUTPUT.PUT_LINE(N);
END;
/

Error starting at line : 8 in command -
DECLARE
  N NUMBER :=&N;
BEGIN
  DBMS_OUTPUT.PUT_LINE(N);
END;
Error report -
ORA-06550: line 2, column 14:
PLS-00103: Encountered the symbol "&" when expecting one of the following:

   ( - + case mod new not null <an identifier>
   <a double-quoted delimited-identifier> <a bind variable>
   continue avg count current exists max min prior sql stddev
   sum variance execute forall merge time timestamp interval
   date <a string literal with character set specification>
   <a number> <a single-quoted SQL string> pipe
   <an alternatively-quoted string literal with character set specification>
   <an alternatively
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Set define on, and try again:

SQL> SET serveroutput ON
SQL> SET DEFINE ON
SQL> DECLARE
  2    N NUMBER :=&N;
  3  BEGIN
  4    DBMS_OUTPUT.PUT_LINE(N);
  5  END;
  6  /
Enter value for n: 10
old   2:   N NUMBER :=&N;
new   2:   N NUMBER :=10;
10

PL/SQL procedure successfully completed.

SQL>
Sign up to request clarification or add additional context in comments.

4 Comments

Its work successfully in SQL developer but it not working in oracle 10g "sql commands". Its says missing or invalid option.
i can not define it proprly but it run in browser which 10g express edition and its "SQL commands " named where execute sql query.
You must tell what exactly you are doing. Which client you are using? At least, tell us if you know about the client?
oracle 10g express edition and i write command in sql commands which open in browser (firefox,chrome etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.