Database Reference
In-Depth Information
Figure 8.20
BREAK Command
Syntax.
We use a dash or hyphen ( - ) to continue the TTITLE command to a sec-
ond line. The CDNUM variable is defined in the script and therefore can be
used in the title. Do not include the ampersand (&) when naming a variable
in the title. LINESIZE was changed to 60, so the title can be seen more easily.
The result of executing this script is shown in Figure 8.19.
The final component of an SQL*Plus report is adding a break within
the report to cause an outlining effect, also called a master detail style
report. You probably have noticed that the CD Title in our report is output
for every line even though it is the same. This does look somewhat clumsy.
You can easily suppress the repeated title by adding the BREAK command.
This means that a repeating element is only printed once. The syntax of the
BREAK command is shown in Figure 8.20.
The BREAK command, like the TTITLE command and other
SQL*Plus commands, is used for your session until you log off or execute
another BREAK command. The following lines could be added to the
beginning of the CDREPORT file:
SET PAGESIZE 40
BREAK ON CDTITLE NODUPLICATES SKIP 2 ON NAME NODUPLICATES
The second line tells SQL*Plus to only display the CDTITLE at the top
of a page or when it changes, to skip 2 lines when it encounters a new
CDTITLE, and to only display the artist's name (the NAME column) at
the top of each page or when it changes. On the first line, changing the
PAGESIZE to 40 lines makes it easier to see the report's breaks.
Also change the WHERE clause so that you are returning all CDs less
than or equal to the number you enter. This will show you how the BREAK
works on the CD titles.
Search WWH ::




Custom Search