Problem with SUM and large integers

Alex IpAlex Ip Australia
edited 1:45AM in FastReport 4.0
G'day all...

We are having a problem in FastReport 4 in Delphi 7 with ZeosLib and PostgreSQL 7.X where int8 fields are not being summed properly. Instead of being summed as integers, the strings representing each of the numbers in the are concatenated.

ZeosLib converts Postgres int8 fields into the Delphi TLargeIntField type - it would appear that FastReports is having some difficulty dealing with this field type. Postgres returns an int8 field for any count(..) value in an SQL statement, so this is a big problem for us. We do not seem to have this issue with TIntegerField or TFmtBCDField datatypes (using Devart dbExpress components for PostgreSQL).

This problem was first reported for FR3 in this post: http://www.fast-report.com/en/forum/index.php?showtopic=3135

Is there a fix for this or can anyone suggest a work-around (other than casting the int8 field to an int4 in the SQL)?

Thanks,

Alex

Comments

  • Alex IpAlex Ip Australia
    edited 1:45AM
    Problem found and fixed. The function frGetFieldValue in the frx2xto30.pas unit assigned the DisplayText (string) value to the variant instead of the Int64 value for TLargeintFields.

    This is the change I made to get it to work:
    function frGetFieldValue(F: TField): Variant;
    begin
      if not F.DataSet.Active then
        F.DataSet.Open;
      if Assigned(F.OnGetText) then
        Result := F.DisplayText
      else if F.DataType in [ftLargeint] then
    {$IFDEF Delphi6}
        Result := TLargeIntField(F).AsLargeInt
    {$ELSE}
        Result := TField(F).AsInteger
    {$ENDIF}
      else
        Result := F.AsVariant;
    
      if Result = Null then
        if F.DataType = ftString then
          Result := ''
        else if F.DataType = ftWideString then
          Result := ''
        else if F.DataType = ftBoolean then
          Result := False
        else
          Result := 0;
    end;
    

    Could you please patch this in future releases?

    Thanks,

    Alex.

Leave a Comment