Problem with Aggregate function results and Numeric Fields

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Problem with Aggregate function results and Numeric Fields

Post by snorkel » Tue 28 Aug 2012 19:09

If I have a field
defined as NUMERIC(28,7) with a column name of test

and I have a few values in there like:
45.67
45.89
etc

and I do

select max(test) from test_table

I get back in the datagrid .E1
if I do a sum on the column I get back .E2

Any ideas?

This works fine in PG Admin III

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem with Aggregate function results and Numeric Fields

Post by AlexP » Wed 29 Aug 2012 09:20

hello,

I cannot reproduce the problem, your code doesn't cause errors. Please specify the exact versions of PgDAC, PostgreSQL Server and IDE.

dschuch
Posts: 75
Joined: Thu 05 Feb 2009 15:29
Location: Dresden

Re: Problem with Aggregate function results and Numeric Fields

Post by dschuch » Wed 29 Aug 2012 11:10

this is a round-problem i think.

postgres itsself works with a precision of 7. if you have another fieldlength in your frontent, you recieve other values.


postgres:

1,1111111
+1,1199999
=2,231111

delphi: (e.g. 2 digit precission)
1,11
+1,12
=2,34

look for your field datatype definition.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem with Aggregate function results and Numeric Fields

Post by AlexP » Wed 29 Aug 2012 12:06

hello,

This problem cannot be reproduced on the latest PgDAC version with standard settings of Connection and Query.
Please try to reproduce the problem on the latest PgDAC version, and if the problem is reproduced, send a small project demonstrating the problem

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Re: Problem with Aggregate function results and Numeric Fields

Post by snorkel » Wed 29 Aug 2012 15:03

I checked the return type and it's coming back as
FMTBcd, I have the enablebcd option enabled, but it does not make a difference.
I am on the last version of pgdac before the requirement for Delphi xe2 update 4.

I will update Delphi to update 4 and then update the pgdac components and see.

It could also be the Devexpress Quantum grid that is having the issue as well.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem with Aggregate function results and Numeric Fields

Post by AlexP » Thu 30 Aug 2012 12:12

hello,

By default, the EnableBCD option is disabled (False) and the type of such field - sum(NUMERIC(28,7)) or max(NUMERIC(28,7)) - is defined as TFloatField, and correct values of executing these aggregate functions are displayed with the correct number of characters after coma. When the EnableBCD option is enabled, the number of characters after coma is 4, since it is the standard precision for this field type. When enabling the EnableFMTBCD option, the number of characters after coma and the value are displayed correctly, just like at TFloatField.
We have checked the behaviour on Delphi XE2 Update 4 HotFix 1, PgDAC 3.2.8, and standard DBGrid.
Try to reproduce the problem on standard settings of our PgConnection, PgQuery components, and on standard DBGrid

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Re: Problem with Aggregate function results and Numeric Fields

Post by snorkel » Thu 30 Aug 2012 16:14

Hi,
Just wanted to let you know updating to the latest Delphi update+ hotfix+ latest PGDac
solved the problem.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Problem with Aggregate function results and Numeric Fields

Post by AlexP » Fri 31 Aug 2012 07:06

Hello,

Glad to see that you solved the problem. If you have any other questions, feel free to contact us.

Post Reply