claghorn
asked on
Bind Variable x is not declared
I get Bind Variable "x" is NOT DECLARED
anonymous block completed
when running the following program.
Can you show me how to declare this so this program will print the value?
declare x NUMBER;
BEGIN
:x := 1;
PRINT :x;
END;
anonymous block completed
when running the following program.
Can you show me how to declare this so this program will print the value?
declare x NUMBER;
BEGIN
:x := 1;
PRINT :x;
END;
ASKER
It did'nt work. Does it work for you?
SQL> declare x NUMBER;
2 BEGIN
3 x := 1;
4 PRINT x;
5 END;
6 /
PRINT x;
*
ERROR at line 4:
ORA-06550: line 4, column 9:
PLS-00103: Encountered the symbol "X" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "X" to continue.
SQL> declare x NUMBER;
2 BEGIN
3 x := 1;
4 PRINT x;
5 END;
6 /
PRINT x;
*
ERROR at line 4:
ORA-06550: line 4, column 9:
PLS-00103: Encountered the symbol "X" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "X" to continue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. My book has some disfunctional code so I had to ask for help on such a seemingly trivial thing. Here's the summary.
SQL> help print
PRINT
-----
Displays the current values of bind variables, or lists all bind
variables.
PRI[NT] [variable ...]
--works
SQL> set serveroutput on;
SQL> declare x NUMBER;
2 BEGIN
3 x := 1;
4 dbms_output.put_line(x);
5 END;
6 /
1
PL/SQL procedure successfully completed.
--works
SQL> variable x NUMBER;
SQL> BEGIN
2 :x := 1;
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> print x;
X
----------
1
SQL> help print
-----
Displays the current values of bind variables, or lists all bind
variables.
PRI[NT] [variable ...]
--works
SQL> set serveroutput on;
SQL> declare x NUMBER;
2 BEGIN
3 x := 1;
4 dbms_output.put_line(x);
5 END;
6 /
1
PL/SQL procedure successfully completed.
--works
SQL> variable x NUMBER;
SQL> BEGIN
2 :x := 1;
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> print x;
X
----------
1
Open in new window