Reputation: 62
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
Upvotes: 2
Views: 1886
Reputation: 49112
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>
Upvotes: 3