Page 1 of 1

Problem with Aggregate function results and Numeric Fields

Posted: Tue 28 Aug 2012 19:09
by snorkel
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

Re: Problem with Aggregate function results and Numeric Fields

Posted: Wed 29 Aug 2012 09:20
by AlexP
hello,

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

Re: Problem with Aggregate function results and Numeric Fields

Posted: Wed 29 Aug 2012 11:10
by dschuch
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.

Re: Problem with Aggregate function results and Numeric Fields

Posted: Wed 29 Aug 2012 12:06
by AlexP
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

Re: Problem with Aggregate function results and Numeric Fields

Posted: Wed 29 Aug 2012 15:03
by snorkel
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.

Re: Problem with Aggregate function results and Numeric Fields

Posted: Thu 30 Aug 2012 12:12
by AlexP
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

Re: Problem with Aggregate function results and Numeric Fields

Posted: Thu 30 Aug 2012 16:14
by snorkel
Hi,
Just wanted to let you know updating to the latest Delphi update+ hotfix+ latest PGDac
solved the problem.

Re: Problem with Aggregate function results and Numeric Fields

Posted: Fri 31 Aug 2012 07:06
by AlexP
Hello,

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