Sql*Plus User’s Guide and Reference


Exiting from a Script with a Return Code


Download 5.34 Mb.
Pdf ko'rish
bet66/103
Sana04.08.2023
Hajmi5.34 Mb.
#1665146
1   ...   62   63   64   65   66   67   68   69   ...   103
Bog'liq
E18404-12

Exiting from a Script with a Return Code
You can include an EXIT command in a script to return a value when the script 
finishes. See the 
EXIT
 command on page 12-60 for more information.
You can include a WHENEVER SQLERROR command in a script to automatically exit 
SQL*Plus with a return code should your script generate a SQL error. Similarly, you 
can include a WHENEVER OSERROR command to automatically exit should an 
operating system error occur. See the 
WHENEVER SQLERROR
 command on 
page 12-199, and the 
WHENEVER OSERROR
 command on page 12-198 for more 
information.
Defining Substitution Variables
You can define variables, called substitution variables, for repeated use in a single 
script by using the SQL*Plus DEFINE command. Note that you can also define 
substitution variables to use in titles and to save your keystrokes (by defining a long 
string as the value for a variable with a short name). 
Example 5–8
Defining a Substitution Variable
To define a substitution variable L_NAME and give it the value "SMITH", enter the 
following command:
DEFINE L_NAME = SMITH
To confirm the variable definition, enter DEFINE followed by the variable name:
DEFINE L_NAME
To list all substitution variable definitions, enter DEFINE by itself. Note that any 
substitution variable you define explicitly through DEFINE takes only CHAR values 
(that is, the value you assign to the variable is always treated as a CHAR datatype). 
Note:
The @@ command may be useful in this example. See the 
@@ 
(double at sign)
 command on page 12-7 for more information.
DEFINE L_NAME = "SMITH" (CHAR)


Using Predefined Variables
5-12
SQL*Plus User's Guide and Reference
You can define a substitution variable of datatype NUMBER implicitly through the 
ACCEPT command. You will learn more about the ACCEPT command.
To delete a substitution variable, use the SQL*Plus command UNDEFINE followed by 
the variable name.

Download 5.34 Mb.

Do'stlaringiz bilan baham:
1   ...   62   63   64   65   66   67   68   69   ...   103




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling