Re: 4GL Report SUM problem
Posted in 1998
On 30 Jun 1998, Michael Hoffman wrote: > I'm running Informix 4gl v. 6.05 on an HP 9000 running HP-UX 10.2. > > My problem: I created a REPORT and have "GROUP SUM" and "SUM" fields. > The main program passes an array to the report. It doesn't. The report might access a global array, but that's a different matter. > The SUMs are performed on one of the arrays elements. Running aggregates on variables which are not passed into the report is dodgy. Your report cannot be a 2-pass report or you'd be shouting much more loudly. Don't consider adding a GROUP PERCENT to your report -- it will become a 2-pass report and you'll be very unhappy. > In the course of Printing each row, I may have changes to the value in that > field. The modifications are done directly on the array field. The new > values print out correctly, but are not reflected in the SUM or GROUP SUM. > Only the original values are included. Seems reasonable to me. The aggregation is done at the start of the processing for a row. If you go changing the data after that, then the report has no way of knowing that -- or it turns a blind eye to it. Would you want a new value added every time the value was changed? What about if you called a function which changed the value? > Any way around this other than creating a "value_change" variable and > modifying the SUM total by the variable's total? Not really -- a do-it-yourself aggregate is probably going to be necessary. I4GL report aggregates are designed to accumulate values passed into the report once per OUTPUT TO REPORT. The further you deviate from this expected use, the less likely they are to be useful. Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix -- see http://www.perl.com/CPAN