Sql*Plus User’s Guide and Reference


Example 5–7 Running a Script


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

Example 5–7
Running a Script
To retrieve and run the command stored in SALES.SQL, enter
START SALES
SQL*Plus runs the commands in the file SALES and displays the results of the 
commands on your screen, formatting the query results according to the SQL*Plus 
commands in the file:
You can also use the @ (at sign) command to run a script:
@SALES
The @ and @@ commands list and run the commands in the specified script in the 
same manner as START. SET ECHO affects the @ and @@ commands in the same way 
as it affects the START command.
To see the commands as SQL*Plus "enters" them, you can SET ECHO ON. The ECHO 
system variable controls the listing of the commands in scripts run with the START, @ 
and @@ commands. Setting the ECHO variable OFF suppresses the listing.
START, @ and @@ leave the last SQL command or PL/SQL block of the script in the 
buffer.
Running a Script as You Start SQL*Plus
To run a script as you start SQL*Plus, use one of the following options:

Follow the SQLPLUS command with your username, a slash, a space, @, and the 
name of the file:
SQLPLUS HR @SALES
SQL*Plus starts, prompts for your password and runs the script.
LAST NAME MONTHLY SALARY COMMISSION %
------------------------- -------------- ------------
Russell $14,000 0.40
Partners $13,500 0.30
Errazuriz $12,000 0.30
Cambrault $11,000 0.30
Zlotkey $10,500 0.20


Defining Substitution Variables
Using Scripts in SQL*Plus
5-11

Include your username as the first line of the file. Follow the SQLPLUS command 
with @ and the filename. SQL*Plus starts, prompts for your password and runs 
the file. 
Nesting Scripts
To run a series of scripts in sequence, first create a script containing several START 
commands, each followed by the name of a script in the sequence. Then run the script 
containing the START commands. For example, you could include the following 
START commands in a script named SALESRPT:
START Q1SALES
START Q2SALES
START Q3SALES
START Q4SALES
START YRENDSLS

Download 5.34 Mb.

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




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