So far you have learned how to view query results at your display terminal. Now produce a printed copy of a query result on the system printer. The information requested to be printed is a copy of the DEPARTMENT table. Begin by entering the following query:
select * - from department - order by deptno
As you can see, this query selects all the columns and all the rows from the DEPARTMENT table. Request a printed copy of this query result by entering the following display command:
Another way to request a printed copy of the query result is to press PF4. Figure 18 illustrates the printed information for the preceding query. Consult the appropriate person at your location for printing procedures.
Each printed page is numbered, dated, and titled. The title consists of the first 100 characters of the SELECT statement that you typed. For information on the creation of report titles, refer to Chapter 5, Formatting Query Results.
Figure 18. Example of a Printed Report
. 07/13/89 SELECT * FROM DEPARTMENT ORDER BY DEPTNO PAGE 1 .
. .
. .
. DEPTNO DEPTNAME MGRNO ADMRDEPT .
. ______ ____________________________ ______ ________ .
. A00 SPIFFY COMPUTER SERVICE DIV. 000010 A00 .
. B01 PLANNING 000020 A00 .
. C01 INFORMATION CENTER 000030 A00 .
. D01 DEVELOPMENT CENTER ? A00 .
. D11 MANUFACTURING SYSTEMS 000060 D01 .
. D21 ADMINISTRATION SYSTEMS 000070 D01 .
. E01 SUPPORT SERVICES 000050 A00 .
. E11 OPERATIONS 000090 E01 .
. E21 SOFTWARE SUPPORT 000100 E01 .
. .
. .
. .
. .
. .
Although this query fits on one display, a long query that requires several displays is also printed entirely, regardless of the rows being displayed when you typed the PRINT command. Also, when the PRINT command completes printing the report, the end rows of the query result are displayed regardless of the rows being displayed when you entered the PRINT command.
The printed report does, however, start with the column that is currently at the left edge of the display, and continues for as many print positions as can fit on the specified page size. You can print reports that are too wide for the page size by entering a PRINT command at column 1, moving the display to start with the column that would not fit on the page, entering another PRINT command, and so on. Page-size specification is discussed in Page Size of Printed Reports.
You may have special printing requirements for your query results (such as the type of paper or its size) that you can specify using the CLASS keyword of the PRINT command. See the PRINT command in Chapter 10, ISQL Commands for a description of this procedure. For DB2 Server for VM, the CLASS value can also be set by a CP SPOOL command.
For three copies, type:
print copies 3
DB2 Server for VM | ||
---|---|---|
You can also use the CP SPOOL command to specify the number of copies. The value for copies that is specified on the CP SPOOL command remains in effect until another value is specified by another CP SPOOL command.
|
You can specify both your print requirements and number of copies with one PRINT command. For example, you can type:
print copies 3 class a
EXERCISE 1 (Answers are in Appendix A, Answers to the Exercises, page ***.) select * - from proj_act - where projno <> 'AD3111' - order by actno,acendate Perform the following:
|