2011/11/24

出力形式の表示順 (Order of output format list)


OTNに「出力形式の順序を変更する方法」が質問されていました。
https://forums.oracle.com/forums/thread.jspa?threadID=514121

スレッドの中で、BI Publisher 10gでの変更方法と思われる回答が寄せられていました。これをヒントに、BI Publisher 11gで表示順序が変更ができるかを検証します。

【変更前の状態】
変更前の状態は以下の通りです。
Figure 1: Original order

【ダウンロード】
対象となるレポートを選択し、ダウンロードします。
Figure 2: Download report

【解凍】
ダウンロードした *.xdozファイルをZIPファイルとして解凍します。

【定義の編集】
解凍されたファイルに含まれる_report.xdoを開きます。
List 1:
<?xml version = '1.0' encoding = 'utf-8'?> <report xmlns="http://xmlns.oracle.com/oxp/xmlp" xmlns:xsd="http://wwww.w3.org/2001/XMLSchema" version="2.0" dataModel="true" useBipParameters="true" producerName="fin-financialCommon" parameterVOName="" parameterTaskFlow="" customDataControl="" cachePerUser="true" cacheSmartRefresh="false" cacheUserRefresh="false"> <dataModel url="/~weblogic/dmEmp.xdm"/> <description/> <property name="showControls" value="true"/> <property name="online" value="true"/> <property name="openLinkInNewWindow" value="true"/> <property name="autoRun" value="false"/> <property name="cacheDocument" value="true"/> <property name="showReportLinks" value="true"/> <property name="asynchronousRun" value="false"/> <property name="useExcelProcessor" value="false"/> <property name="cacheDuration" value="30"/> <property name="controledByExtApp" value="false"/> <parameters paramPerLine="3"/> <templates default="layout1"> <template label="layout1" url="layout1.rtf" type="rtf" outputFormat="html,pdf,rtf,excel,xlsx,pptx,csv" defaultFormat="html" locale="en_US" disableMasterTemplate="true" active="true" viewOnline="false"/> </templates> </report> 

下線部を編集します。
List 2:
<templates default="layout1"> <template label="layout1" url="layout1.rtf" type="rtf" outputFormat="csv,pptx,xlsx,excel,rtf,pdf,html" defaultFormat="html" locale="en_US" disableMasterTemplate="true" active="true" viewOnline="false"/> </templates>

【圧縮】
編集後、ファイルを再度ZIP形式で圧縮し、拡張子を.xdozに変更します。


【アップロード】
ファイルをアップロードします。
Figure 3: Upload

【結果】
出力形式の表示順が_report.xdoで指定した順に変わっていることが確認できます。
Figure 4: Result - order changed.

なお、残念ながら、変更後にレポートの定義を編集・保存すると表示順は元に戻ってしまいます。


[summary]


OTN thread: Default output format
https://forums.oracle.com/forums/thread.jspa?threadID=514121


The solution on BI Publisher 10g is posted on the thread above.  I've checked if this solution works on BI Publisher 11g as well.
You can change the order of output format with the following step:


1) Download the report (See Figure 2).
2) Unzip the download file (*.xdoz).
3) Edit _report.xdo (See List 1 and 2).
4) Zip the files again, and upload it onto BI Publisher (Figure 3).


Note that the order of output format will be reset when you edit and save the report.

2011/11/21

SCOTT スキーマ (SCOTT schema)

SCOTTって何ですか」という質問がありました。このブログではサンプルの説明には特にことわりもなくSCOTTスキーマを使用してきましたが、言われてみれば、古くからOracle DBを使用されている方でない限り、知る由のないスキーマではあります。

昔日の頃、プログラム言語を学ぶ際に最初に表示する文字列が「Hello World!」であるのと同じく、Oracle DBを学ぶ際に最初に使用するサンプルスキーマはSCOTTスキーマでした。
現行バージョン(Oracle 11gR2)でも %ORACLE_HOME%/rdbms/admin/utlsampl.sql で作成することができます。

ER図は以下のPDFで参照することができます。
http://www.datamasker.com/DMO/HelpFiles/ScottERDiagram.pdf


[Summary]
I've got a question "What is SCOTT?" - now I know SCOTT is no longer popular for the engineers under 30.
Young people, please see the file %ORACLE_HOME%/rdbms/admin/utlsampl.sql.


ER diagram is available:
http://www.datamasker.com/DMO/HelpFiles/ScottERDiagram.pdf

2011/11/17

SQLで小計と合計を取得する:補足 (SQL: Subtotal and Grand Total: Appendix)

前回の記事で、処理性能の検証結果に「非効率なSQLの例」を載せ忘れていましたので掲載します。
また、group by および group by rollup()の例も併せて再掲します。

List 8:
********************************************************************************

select *
  from (
       select deptno, job, sum(sal) sum_sal
         from emp2
        group by deptno, job
       union
       select deptno, null as job, sum(sal) sum_sal
         from emp2
        group by deptno
       union
       select null as deptno, null as job, sum(sal) sum_sal
         from emp2
       )
 order by deptno, job

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.01          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      1.10       1.41      25695      50853          0          13
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      1.10       1.43      25695      50853          0          13

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 86  

Rows     Row Source Operation
-------  ---------------------------------------------------
     13  SORT ORDER BY (cr=50853 pr=25695 pw=0 time=0 us cost=1083 size=480 card=15)
     13   VIEW  (cr=50853 pr=25695 pw=0 time=120 us cost=1082 size=480 card=15)
     13    SORT UNIQUE (cr=50853 pr=25695 pw=0 time=36 us cost=1082 size=190 card=15)
     13     UNION-ALL  (cr=50853 pr=25695 pw=0 time=192 us)
      9      HASH GROUP BY (cr=16951 pr=8565 pw=0 time=32 us cost=248 size=165 card=11)
1200000       TABLE ACCESS FULL EMP2 (cr=16951 pr=8565 pw=0 time=2393598 us cost=239 size=1800000 card=120000)
      3      HASH GROUP BY (cr=16951 pr=8565 pw=0 time=202 us cost=248 size=21 card=3)
1200000       TABLE ACCESS FULL EMP2 (cr=16951 pr=8565 pw=0 time=2320510 us cost=239 size=840000 card=120000)
      1      SORT AGGREGATE (cr=16951 pr=8565 pw=0 time=0 us cost=587 size=4 card=1)
1200000       TABLE ACCESS FULL EMP2 (cr=16951 pr=8565 pw=0 time=1736062 us cost=239 size=480000 card=120000)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  direct path read                                8        0.00          0.01
  asynch descriptor resize                        5        0.00          0.00
  SQL*Net message from client                     2        0.01          0.01
********************************************************************************

select deptno, job, sum(sal) sum_sal
  from emp2
 group by deptno, job
 order by
       deptno, job

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.54       0.53         15       8580          0           9
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.54       0.53         15       8580          0           9

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 86  

Rows     Row Source Operation
-------  ---------------------------------------------------
      9  SORT GROUP BY (cr=8580 pr=15 pw=0 time=0 us cost=284 size=135 card=9)
1200000   TABLE ACCESS FULL EMP2 (cr=8580 pr=15 pw=0 time=2297470 us cost=245 size=18000000 card=1200000)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  db file sequential read                        15        0.00          0.00
  SQL*Net message from client                     2        0.00          0.00
********************************************************************************

select deptno, job, sum(sal) sum_sal
  from emp2
 group by rollup (deptno, job)
 order by
       deptno, job

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        2      0.54       0.56         17       8580          0          13
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.54       0.56         17       8580          0          13

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 86  

Rows     Row Source Operation
-------  ---------------------------------------------------
     13  SORT GROUP BY ROLLUP (cr=8580 pr=17 pw=0 time=0 us cost=284 size=195 card=13)
1200000   TABLE ACCESS FULL EMP2 (cr=8580 pr=17 pw=0 time=2089726 us cost=245 size=18000000 card=1200000)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       2        0.00          0.00
  db file sequential read                        17        0.00          0.00
  SQL*Net message from client                     2        0.01          0.01





[Summary]
I forgot to put the trece of Bad Example in the last post.
Here List 8 shows the results of three SQL - bad example, group by and group by rollup.