Sql*Plus User’s Guide and Reference


Download 5.34 Mb.
Pdf ko'rish
bet101/103
Sana04.08.2023
Hajmi5.34 Mb.
#1665146
1   ...   95   96   97   98   99   100   101   102   103
Bog'liq
E18404-12

Example 6–26
Sending Query Results to a Printer
To generate a final report and spool and print the results, create a script named 
EMPRPT containing the following commands.
First, use EDIT to create the script with your operating system text editor. 
EDIT EMPRPT
Next, enter the following commands into the file, using your text editor:
SPOOL TEMP
CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES
COLUMN DEPARTMENT_ID HEADING DEPARTMENT
COLUMN LAST_NAME HEADING 'LAST NAME'
COLUMN SALARY HEADING 'MONTHLY SALARY' FORMAT $99,999
BREAK ON DEPARTMENT_ID SKIP 1 ON REPORT
COMPUTE SUM OF SALARY ON DEPARTMENT_ID
COMPUTE SUM OF SALARY ON REPORT


Storing and Printing Query Results
6-28
SQL*Plus User's Guide and Reference
SET PAGESIZE 24
SET NEWPAGE 0
SET LINESIZE 70
TTITLE CENTER 'A C M E W I D G E T' SKIP 2 -
LEFT 'EMPLOYEE REPORT' RIGHT 'PAGE:' -
FORMAT 999 SQL.PNO SKIP 2
BTITLE CENTER 'COMPANY CONFIDENTIAL'
SELECT DEPARTMENT_ID, LAST_NAME, SALARY
FROM EMP_DETAILS_VIEW
WHERE SALARY>12000
ORDER BY DEPARTMENT_ID;
SPOOL OFF
If you do not want to see the output on your screen, you can also add SET TERMOUT 
OFF to the beginning of the file and SET TERMOUT ON to the end of the file. Save 
and close the file in your text editor (you will automatically return to SQL*Plus). Now, 
run the script EMPRPT:
@EMPRPT
SQL*Plus displays the output on your screen (unless you set TERMOUT to OFF), and 
spools it to the file TEMP:
A C M E W I D G E T
EMPLOYEE REPORT PAGE: 1
DEPARTMENT LAST NAME MONTHLY SALARY
---------- ------------------------- --------------
20 Hartstein $13,000
********** --------------
sum $13,000
80 Russell $14,000
Download 5.34 Mb.

Do'stlaringiz bilan baham:
1   ...   95   96   97   98   99   100   101   102   103




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