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