home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / oracle / 2171 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  5.1 KB

  1. Path: sparky!uunet!mcsun!news.funet.fi!hydra!klaava!cc.helsinki.fi!jaakola
  2. From: jaakola@cc.helsinki.fi
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: SQL*REP - how to reset &Page variable to 1
  5. Message-ID: <1992Nov11.175809.1@cc.helsinki.fi>
  6. Date: 11 Nov 92 15:58:09 GMT
  7. References: <fragante.721444309@unixg.ubc.ca>
  8. Sender: news@klaava.Helsinki.FI (Uutis Ankka)
  9. Organization: University of Helsinki
  10. Lines: 171
  11.  
  12. In article <fragante.721444309@unixg.ubc.ca>, fragante@unixg.ubc.ca (Gv Fragante) writes:
  13. > I remember seeing this question posted a few months back but missed reading it.
  14. > So if anyone can remember, how can I reset the page number to 1 after a group
  15. > break ? Also, how can I make SQL*REP pause after each group break ? I need
  16. > the pause to allow the user to insert a special stationary into the laser
  17. > printer.
  18. > Thanks.
  19.  
  20. Here it is again:
  21.  
  22. Week ago I requested help on resetting page numbers when a record in
  23. a master group changes. VSOOD@us.oracle.com posted me a solution for
  24. SQL*ReportWriter version 1.1 which used an user exit written in Pro*C.
  25. Inspired by that I discovered a new way to reset page numbers which
  26. does not need any Pro*C, just plain brute force &SQL-kludges. This
  27. solution does not affect detail groups in any way; all extra fields
  28. are placed at REPORT and master levels.
  29.  
  30. PLEASE NOTE THAT IN SQL*REPORTWRITER VERSION 2 THERE WILL BE A
  31. BUILT-IN WAY TO RESET PAGE NUMBER WHEN RECORD CHANGES! And in version
  32. 2 you cannot have fields with source &PAGE any more...
  33.  
  34. The example below demonstrates that
  35.   - this works for details returning no rows
  36.   - this works for master - multiple details -reports
  37.  
  38. I can see no reason why this wouldn't work for master-detail-detail
  39. reports; I have not tried it, though.
  40.  
  41. This is my report like:
  42.  
  43. QUERY:
  44.   dept:
  45.     query:
  46.        SELECT deptno
  47.        FROM dept
  48.  
  49.   emp:
  50.     query:
  51.        SELECT deptno, ename
  52.        FROM emp
  53.        WHERE deptno = :deptno
  54.     parent query 1: dept
  55.     Do NOT enter any records for "Child Columns/Parent 1 Columns"!
  56.  
  57.   manager:
  58.     query:
  59.        SELECT ename managername
  60.        FROM emp
  61.        WHERE deptno = :deptno
  62.          AND job = 'MANAGER'
  63.     parent query 1: dept
  64.     Do NOT enter any records for "Child Columns/Parent 1 Columns"!
  65.  
  66. GROUP:
  67.   G_dept:
  68.     page break: Always
  69.   G_emp:
  70.     relative position: Below
  71.   G_manager:
  72.     relative position: Below
  73.  
  74. FIELD:
  75.   FieldName    Source       Group      DataType  Width  Skip
  76.   ---------    ------       -----      --------  -----  ----
  77.   oldmaster    #RWENOP      REPORT     CHAR      30
  78.   realpage     &PAGE        REPORT     NUM        3
  79.   virtpage     #RWENOP      G_dept     NUM        3     X
  80.   firstpage    (1)          G_dept     NUM        3     X
  81.   DEPTNO       dept.DEPTNO  G_dept     NUM        4
  82.   forcecalc    (2)          G_dept     NUM        3     X
  83.   DEPTNO2      emp.DEPTNO   G_emp      NUM        4
  84.   ENAME        ENAME        G_emp      CHAR      10
  85.   MANAGERNAME  MANAGERNAME  G_manager  CHAR      10
  86.  
  87.   where (1) is
  88.     &SQL SELECT DECODE(:oldmaster,
  89.                   :deptno,:firstpage,
  90.                   :realpage),
  91.            :deptno
  92.          INTO :firstpage,
  93.            :oldmaster
  94.          FROM dual
  95.  
  96.   and (2) is
  97.     &SQL SELECT :realpage - :firstpage + 1
  98.          INTO :virtpage
  99.          FROM dual
  100.  
  101.   The fields oldmaster, realpage, virtpage, firstpage and forcecalc were
  102.   created manually.
  103.  
  104. SUMMARY:
  105.  
  106.   SummaryName   Field     Function  DataType  Width  PrintGroup  ResetGroup
  107.   -----------   -----     --------  --------  -----  ----------  ----------
  108.   virtpagesum   virtpage  Last      NUM       3      G_dept      PAGE
  109.  
  110. TEXT:
  111.  
  112.   place &virtpagesum on the PAGE Header and enjoy!
  113.  
  114.   The "repeat on page overflow" is crossed by default for G_dept
  115.   objects; I have not tested what happens if it's not crossed.
  116.  
  117. I tested it by setting Report Page Height to 12 and here is the result:
  118. (please note that ^L stands for form feed)
  119.  
  120.                                              PAGE:   1
  121. Deptno
  122. ------
  123.     10
  124.   Deptno  Ename
  125.   ------  ----------
  126.       10  CLARK
  127.       10  KING
  128. ^L
  129.  
  130.                                              PAGE:   2
  131. Deptno
  132. ------
  133.     10
  134.   Deptno  Ename
  135.   ------  ----------
  136.       10  MILLER
  137. ^L
  138.  
  139.                                              PAGE:   3
  140. Deptno
  141. ------
  142.     10
  143.     Managername
  144.     -----------
  145.     CLARK
  146. ^L
  147.  
  148.                                              PAGE:   1
  149. Deptno
  150. ------
  151.     20
  152.   Deptno  Ename
  153.   ------  ----------
  154.       20  SMITH
  155.       20  JONES
  156. ^L
  157. [stuff deleted]
  158. ^L
  159.  
  160.                                              PAGE:   1
  161. Deptno
  162. ------
  163.     40
  164.   Deptno  Ename
  165.   ------  ----------
  166.     Managername
  167.     -----------
  168.  
  169. I tried to get rid of the summary, but the virtpage seems to "lag" one
  170. page behind! I discovered one solution without a summary, but it worked
  171. only if DESTYPE=Screen - if I set DESTYPE=File the page numbers do not
  172. reset! My runrep's version is 1.1.12.2.2 on MS-DOS and we have discovered
  173. other annoying inconsistencies between File and Screen desformats.
  174.  
  175. If you have a solution which eliminates the summary, please let me know!
  176. --
  177. Juhani Jaakola        jaakola@CC.Helsinki.FI
  178. Phone: +358-0-506811  (or +358-0-13431405)
  179. Fax:   +358-0-50681300
  180. Address: Sulkapolku 4 B 13 A
  181.          00370 Helsinki
  182.