【发布时间】:2017-01-13 03:36:54
【问题描述】:
我正在学习如何编写基本的 SQL*Plus 报告。
在练习时,我遇到了 BREAK ON 命令的问题,不知道如何继续。
作为参考,正在使用的表格称为“报纸”,它包含报纸中专题的名称、该专题所在的版块以及该专题所在的页面。
运行以下报告时,SQL*Plus 按预期返回结果:
rem Newspaper Report
ttitle 'Newspaper Features by Section'
btitle 'Hot off the Presses'
column feature format a15 word_wrapped
column section format a7
column page format 99
column feature heading 'Feature'
column section heading 'Section'
column page heading 'Page'
break on section skip 1
set linesize 80
set pagesize 40
set newpage 0
set feedback off
spool test.sql
select section, feature, page from newspaper
order by section;
spool off
输出:
Section Feature Page
------- --------------- ----
A National News 1
Editorials 12
B Bridge 2
Movies 4
Modern Life 1
Television 7
C Comics 4
Weather 2
D Sports 1
E Business 1
F Obituaries 6
Classified 8
Doctor Is In 6
Births 7
在本例中,SQL*Plus 在遇到新特性时会跳过一行。这就是预期的工作方式。
但是,当我执行以下报告时,我的结果并没有按照应有的方式格式化:
rem Newspaper Report
ttitle 'Newspaper Features by Page'
btitle 'Hot off the Presses'
column feature format a15 word_wrapped
column section format a7
column page format 99
column feature heading 'Feature'
column section heading 'Section'
column page heading 'Page'
break on page skip 1
set linesize 80
set pagesize 40
set newpage 0
set feedback off
spool test.sql
select page, feature, section from newspaper
order by page;
spool off
输出:
Page Feature Section
---- --------------- -------
1 Modern Life B
Sports D
National News A
Business E
2 Weather C
Bridge B
4 Movies B
Comics C
6 Doctor Is In F
Obituaries F
7 Television B
Births F
8 Classified F
12 Editorials A
页面更改时没有跳过任何行。我做错了什么还是命令以这种方式受到限制?
【问题讨论】: