DB2 Server for VSE & VM: Interactive SQL Guide and Reference


Obtaining a Printed Report

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:

   print

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.

Obtaining Multiple Copies of a Printed Report

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.
Note:If you specify the number of copies on the PRINT command after you specified it using a CP SPOOL command, the PRINT command quantity is used for that print operation. All following PRINT commands use the quantity specified by the CP SPOOL command, unless you specify it using the COPIES keyword.

Using More Than One Keyword with the Print 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 ***.)

Enter the following command:

   select * -
   from proj_act -
   where projno <> 'AD3111' -
   order by actno,acendate

Perform the following:


  1. Move the display so that it begins with the 40th row of the query
    result.
  2. Display the end of the query result.
  3. Move the display so that it begins with the second column of the query
    result.
  4. Move the display so that it begins with the first column of the query
    result.
  5. Move the display so that it begins with the first row of the query
    result.
  6. Request a printed copy of this result.
  7. End the query result.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]