Recent

Author Topic: Fortes report - mysql formula returns TFMTBCDField, FR shows 0  (Read 2597 times)

grandehombre

  • New Member
  • *
  • Posts: 42
I am using Lazarus 1.0.10 and FortesReport 3.24.LCLR2 on Win7-74 PC.
I connect to a MySQL db using TMySQL50Connection.
The SQL contains
Code: [Select]
SUM(myMAQQty) AS qty, SUM(myMAQCost * myMAQQty) AS cost
The report has a detail field that shows 'cost'. This shows up correctly.
It also has a summary band that shows a TDBResult, iSum of 'cost'.
The output is always 0, which is incorrect.

However, the qty field (used in the details and summary bands, just like 'cost') shows correctly.

The qty field shows up (in the object browser) as a TFloatField, whereas the cost field shows up as TFMTBCDField.

Tracing it through RLReport.pas, shows that (in TRLCustomDBResult.ComputeDetail(), near line 8372) the call to VarIsNumeric() returns false for the cost field, which is of type TFMTBCDField.

If I change the code in RLReport.pas (near line 8372) from

Code: [Select]
 
if VarIsNumeric(fieldvalue) then
    fSum:=fSum+fieldvalue;
 

to

Code: [Select]
  var flt: float;
...
...
 
  if VarIsNumeric(fieldvalue) then begin
    fSum:=fSum+fieldvalue;
  end else if TryStrToFloat(fieldvalue, flt) then begin
    fSum:=fSum+flt;
  end;
it works.

I should point out that this report worked fine with ODBC-->MSAccess.
It only started failing when I switched to MySQL v5.0

Has anyone else had any similar issues?
« Last Edit: August 06, 2013, 04:55:17 pm by grandehombre »
Lazarus v1.2RC2  i386-win32-win32/win64,  FPC v2.6.2, svn43696 on Win7-64 and win8.1

 

TinyPortal © 2005-2018