基本 SQL*Plus 报告:中断命令未按预期工作
Basic SQL*Plus Report: Break On Command Not Working as Intended
我正在学习如何编写基本 SQL*Plus 报告。
在练习时,我 运行 在使用 BREAK ON 命令时遇到了麻烦,并且不确定如何继续。
作为参考,正在使用的 table 称为 "Newspaper",它包含报纸中某个专题的名称、该专题在哪个版块以及该专题在哪个页面。
当运行如下报告时,SQL*加上returns结果如预期:
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
页面切换时没有跳过任何行。是我做错了什么还是命令被这样限制了?
在我看来问题是列名是 "Page";因为页面是 BREAK ACTION。您能否尝试将该列别名为 "page" 以外的别名并尝试这样做:例如:
column page_temp heading 'Page'
break on page_temp skip 1
set linesize 80
set pagesize 40
set newpage 0
set feedback off
spool test.sql
select page page_temp, feature, section from newspaper
order by page;
我正在学习如何编写基本 SQL*Plus 报告。
在练习时,我 运行 在使用 BREAK ON 命令时遇到了麻烦,并且不确定如何继续。
作为参考,正在使用的 table 称为 "Newspaper",它包含报纸中某个专题的名称、该专题在哪个版块以及该专题在哪个页面。
当运行如下报告时,SQL*加上returns结果如预期:
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
页面切换时没有跳过任何行。是我做错了什么还是命令被这样限制了?
在我看来问题是列名是 "Page";因为页面是 BREAK ACTION。您能否尝试将该列别名为 "page" 以外的别名并尝试这样做:例如:
column page_temp heading 'Page'
break on page_temp skip 1
set linesize 80
set pagesize 40
set newpage 0
set feedback off
spool test.sql
select page page_temp, feature, section from newspaper
order by page;