Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Midas/TClientDataSet    [ Add a report in this area ]  
Report #:  127727   Status: Closed
[Regression in XE7] TAggregateField not working
Project:  Delphi Build #:  21.0.17017.3725
Version:    21.0 Submitted By:   Fernando Rizzato Rizzato
Report Type:  Crash / Data loss / Total failure Date Reported:  9/19/2014 11:36:13 AM
Severity:    Critical / Show Stopper Last Updated: 11/13/2014 4:57:40 PM
Platform:    All versions Internal Tracking #:   55384
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE7 Update1
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When using a Aggregate over a database field, doing a SUM() for example, the resulting value is zero or a "crazy" number.

It works fine on XE6.
Steps to Reproduce:
See attached sample.

[Unit1.dfm]
-----------------
...
  object cdsT01R_T00Q: TClientDataSet
    Aggregates = <>
    AggregatesActive = True
    DataSetField = cdsT00QqryT01R_T00Q
    Params = <>
    OnCalcFields = cdsT01R_T00QCalcFields
    OnNewRecord = cdsT01R_T00QNewRecord
    Left = 672
    Top = 80
    ...
    ...
    object cdsT01R_T00QC01R_QTDE: TFMTBCDField
      FieldName = 'C01R_QTDE'
      ProviderFlags = [pfInUpdate]
      Precision = 12
      Size = 4
    end
    ...
    ...
    object cdsT01R_T00QQTDE: TFloatField
      FieldKind = fkInternalCalc
      FieldName = 'QTDE'
    end
    object cdsT01R_T00QQTDTOTAL: TAggregateField
      FieldName = 'QTDTOTAL'
      Active = True
      DisplayName = ''
      Expression = 'SUM(C01R_QTDE+1)'
    end
    object cdsT01R_T00QQTDTOTAL2: TAggregateField
      FieldName = 'QTDTOTAL2'
      Active = True
      DisplayName = ''
      Expression = 'SUM(QTDE)'
    end
  end
...
-----------------
Workarounds
None
Attachment
AggregateFields.zip
Comments

Tomohiro Takahashi at 9/21/2014 2:45:05 AM -
I checked attached project. So, in order to reproduce your issue, TSQLConnect(dbExpress) for MSSQL and the table schema etc. are needed?
If not, could you please re-attach simpler sample project without dbExpress?

Kelver Merlotti at 9/23/2014 10:09:06 AM -
In the attached file, there's a file called "script.sql" that creates a database called "IG" with the tables and data needed to reproduce. You'll just need to change SQLConnection params to your host/server, user and password.

When run, try to add a new line in the detail grid, and you'll see one of the aggregates working, and the other don't. The one who works is a SUM in an InternalCalc field, and the on who doesn't, is a SUM in a DB Field.

Kelver Merlotti at 9/25/2014 1:48:50 PM -
The "+1" in the SUM expression was just a test. When using only SUM(C01R_QTDE), the value is always 0, like the expression was never evaluated... when using SUM(C01R_QTDE+1) or SUM(C01R_QTDE*1), a "crazy" result is shown.

Paul Morey at 10/8/2014 7:47:26 AM -
I can confirm that aggregate calculations are also broken when using IBX components with ClientDataset. This is a CRITICAL issue!!! When will a hot-fix be issued?

Vyacheslav Romanov at 11/11/2014 1:43:06 AM -
I confirm this issue.
And
1).
a)TAggregateFiels.Expression=sum(TLargeInt) working correctly
b)TAggregateFiels.Expression=sum(TFMTBCDField) is not  correctly. Probably source of error#127703 and #127727 is same.
2). In run-time on big DataSets this issue causes the program to Access Violation and Crash.

Vyacheslav Romanov at 11/11/2014 1:55:18 AM -
P.S. Result of use TAggregateField and TClientDataset.Aggregates is same.

Server Response from: ETNACODE01