About
The arguments of a script become become substitution variable:
- &1 for the first one,
- &2 for the second one,
- etc ….
SQL*PLUS doesn't have any flow control (IF statement), you have to do them in SQL or PL/SQL.
Articles Related
Initialization
If no argument has been given, you can still initialize them with this snippet:
column 1 new_value 1
column 2 new_value 2
set termout off
select null as "1"
, null as "2"
from dual
where 1=2;
set termout on
PROMPT The value for the first argument is: &1
PROMPT The value for the second argument is: &2
DEFINE 1
DEFINE 2
UNDEFINE 1
UNDEFINE 2
Example:
@myScript 1
The value for the first argument is: 1
DEFINE 1 = "1" (CHAR)
The value for the second argument is:
DEFINE 2 = "" (CHAR)
The variable 2 is NULL and can be tested with the function NVL.