home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / database / informix / 1904 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  1.9 KB

  1. Path: sparky!uunet!olivea!gossip.pyramid.com!pyramid!infmx!news
  2. From: cortesi@informix.com (David Cortesi)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re: FOR loop in ACE - bug?
  5. Message-ID: <1992Sep9.205918.2900@informix.com>
  6. Date: 9 Sep 92 20:59:18 GMT
  7. References: <1992Sep9.104715.4047@spider.co.uk>
  8. Sender: news@informix.com (Usenet News)
  9. Reply-To: cortesi@informix.com
  10. Organization: Informix Software, Inc.
  11. Lines: 45
  12.  
  13. In article <1992Sep9.104715.4047@spider.co.uk> ivan@spider.co.uk (Ivan Reid)  
  14. writes:
  15. > {Extract of report to perform repeated summations of columns for a period}
  16.  
  17. [abbreviated by me for clarity, logic unchanged i think! -- DC ]
  18.  
  19. > VARIABLE mx integer    {month}
  20. > VARIABLE yx integer    {year}
  21. > VARIABLE sm integer    {start month}
  22. > VARIABLE em integer    {end month}
  23. > ....
  24. > LET sm=4
  25. > LET em=12
  26. > ....
  27. > ON LAST ROW
  28. >    FOR mx = sm TO em
  29. >    DO BEGIN    {A}
  30. >     LET totalA = GROUP TOTAL OF columname 
  31. >              WHERE month=mx AND year=yx
  32. >     ... <lots of code> ...
  33. >     PRINT .....
  34. >       END    {B}
  35. >    END   
  36. > The FOR loop control values work and are PRINTed ok, but the GROUP
  37. > TOTALs don't work as they should.
  38.  
  39. wait a minute, wait a minute!  You are on the LAST ROW of a
  40. report, and you want to take group totals based on variables
  41. that you are changing *in* the LAST ROW block???
  42.  
  43. That isn't my understanding of how reporting works! 
  44. Group totals are accumulated while the rows are being
  45. processed.  By the time you get to LAST row, all the other
  46. rows that you might have accumulated are **gone**!  How do
  47. you expect ACE to accumulate these totals?  Read the input
  48. over again once for each pass through the FOR loop? 
  49.  
  50. Or, as it plainly says (ISQL 4.0 manual, page 5-83R, note 2):
  51.  
  52.    Aggregates produce unpredictable results when _expr1_ or _expr2_
  53.    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  54.    contains user-defined variables.
  55.  
  56. Which rather exactly sums up your situation, doesn't it?
  57.