Great!
A reader, March 18, 2021 - 8:51 pm UTC
Sir, I executed exactly these commands as you did. I executed them in Version: 11.1.0.6.0
Could this version be problem? which was not letting to execute these commands.
This problem occurs at my side
A reader, March 18, 2021 - 8:53 pm UTC
SQL> VARIABLE tmp_var VARCHAR2(10)=Smith
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n [CHAR|BYTE]) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | BLOB | BFILE
REFCURSOR | BINARY_FLOAT | BINARY_DOUBLE ] ]
support for input binding on "variable" command
Rajeshwaran Jeyabal, March 20, 2021 - 3:32 pm UTC
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqpug/release-changes.html#GUID-27FF7BCE-6111-4872-8FA1-0F412610290D ....
Support for input binding by using the VARIABLE command. The VARIABLE command now supports input binding which can be used in SQL and PL/SQL statements.
....
As mentioned on the docs, it is a new feature of SQL*Plus version 12.2 and above.
so you should be using the sql*plus version 12.2 and above to get it worked.
demo@XEPDB1> variable x number = 55
demo@XEPDB1> exec dbms_output.put_line('x = '||:x);
x = 55
PL/SQL procedure successfully completed.
demo@XEPDB1> print x
X
----------
55
demo@XEPDB1> $ sqlplus -version
SQL*Plus: Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
March 22, 2021 - 7:30 am UTC
sounds like its time to upgrade :-)