SQL Plus - Argument

Card Puncher Data Processing

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.

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.





Discover More
Card Puncher Data Processing
SQL Plus - Script

You must include: a semicolon at the end of each SQL command and a slash (/) on a new line at the end of each PL/SQL block with the @ or the start command where: The exit error...
Card Puncher Data Processing
SQL Plus - Start Command

Runs the SQLPlus statements in the specified script. The script can be called from the local file system or a web server. where: url supports HTTP and FTP protocols in the form: ...



Share this page:
Follow us:
Task Runner