Money field problem
Moderators: gto, cipto_kh, EgonHugeist, olehs
Money field problem
Hi all,
I am new in forum. I have a question.
I use postgresql for my database application and I use Delphi 7 for programming. In delphi, I use Zeos6.6.6 components to connect to postgresql from delphi.
All values in money fields in postgresql table come to dbgrid as 0(zero) values. Namely, real values in money fields don't come to ZTable or ZQuery as real in Delphi.
if you help me, I will be able to happy.
thanks
I am new in forum. I have a question.
I use postgresql for my database application and I use Delphi 7 for programming. In delphi, I use Zeos6.6.6 components to connect to postgresql from delphi.
All values in money fields in postgresql table come to dbgrid as 0(zero) values. Namely, real values in money fields don't come to ZTable or ZQuery as real in Delphi.
if you help me, I will be able to happy.
thanks
Any solution with this , i can add it on pgadmin or even on the grid but it show 0 , which means grid can write but cant read .
Any solution for this ?
This would be good, because on delphi currency calculations have a precision that float doesnt have, when we calc with float the rounds are done with a method that not every time is correct , but with currency is correct.
Why we use a database normaly is only to store data and applications do the calculation ( so float on postgres is error safe but calc are needed on client side not on server side, and is a bit mess to getting all float field and add a mask of 0.00 € manually ) so it shouldnt be deprecaded on zeos.
Thanks
Any solution for this ?
This would be good, because on delphi currency calculations have a precision that float doesnt have, when we calc with float the rounds are done with a method that not every time is correct , but with currency is correct.
Why we use a database normaly is only to store data and applications do the calculation ( so float on postgres is error safe but calc are needed on client side not on server side, and is a bit mess to getting all float field and add a mask of 0.00 € manually ) so it shouldnt be deprecaded on zeos.
Thanks
where's the code ..
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
the docs of PG says this type is deprecated. But i've fixed this in branch tsting and my private branch testing-egonhugeist. PG results the regional-currency as prefix like €+2.000,12 which breaks the rules of StrToFloatDef. Problem 1: the prefix. Problem 2 the wrong defined thausends and floating-point operaters.
So can you please test my branch and do some additional bug-reports?
Best regards EgonHugeist
So can you please test my branch and do some additional bug-reports?
Best regards EgonHugeist
Best regards, Michael
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/
Where can i get your branch test ?
Why Money a float and not delphi currency ? Being currency is better because several components have already prepared for currency.
Even so float calc have round errors with will cause a huge money deviation on a calc, with a few line it could cause more than 1 euro deviation.
I looking for the code and i dont found where it gets the value from pg and convert it to dataset value, can you send me the filename
Why Money a float and not delphi currency ? Being currency is better because several components have already prepared for currency.
Even so float calc have round errors with will cause a huge money deviation on a calc, with a few line it could cause more than 1 euro deviation.
I looking for the code and i dont found where it gets the value from pg and convert it to dataset value, can you send me the filename
where's the code ..
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
This is a Zeos-Internal function, which works generally with the Extendet-type. So don't worry everything is fine..sfxcc wrote:Where can i get your branch test ?
Why Money a float and not delphi currency ? Being currency is better because several components have already prepared for currency.
You can get thew sources either on http://zeoslib.svn.sourceforge.net/view ... es/testing or
http://zeoslib.svn.sourceforge.net/view ... gonhugeist
for the last one you have to know more about. Look at http://zeos.firmos.at/viewtopic.php?t=3427
Best regards, Michael
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/
I have done a simple change, try it out it worked because it results R$0,00
so it have R and , not correct it depends on location.
I change a value from a grid to 4,3 (Money on pg ) and it prints out 4,30000019073486
which is that round error i was talking about, can you check this and please change it to currency. it didnt even show the € not round to 2 places etc and the biggest prob is we use money to do calc with it .. is supposed to be the most accuracy or big probs coming out.
Money=ftFloat should be Money = ftCurrency delphi have this currency to avoid miscaculation with usual float error because math processor.
so it have R and , not correct it depends on location.
I change a value from a grid to 4,3 (Money on pg ) and it prints out 4,30000019073486
which is that round error i was talking about, can you check this and please change it to currency. it didnt even show the € not round to 2 places etc and the biggest prob is we use money to do calc with it .. is supposed to be the most accuracy or big probs coming out.
Money=ftFloat should be Money = ftCurrency delphi have this currency to avoid miscaculation with usual float error because math processor.
function SQLStrToFloatDef(Str: string; Def: Extended): Extended;
var
{$IFDEF DELPHI12_UP}
OldDecimalSeparator: WideChar;
OldThousandSeparator: WideChar;
{$ELSE}
OldDecimalSeparator: Char;
OldThousandSeparator: Char;
{$ENDIF}
aSymbolPos: Integer;
begin
OldDecimalSeparator := DecimalSeparator;
OldThousandSeparator := ThousandSeparator;
// DecimalSeparator := '.';
// ThousandSeparator := ',';
aSymbolPos := Pos('$', Str);
if aSymbolPos > 0 then
Str := Copy(Str, aSymbolPos+1, Pred(Length(Str)));
If Str = '' then
Result := Def
else
Result := StrToFloatDef(Str, Def);
DecimalSeparator := OldDecimalSeparator;
ThousandSeparator := OldThousandSeparator;
end;
where's the code ..
- EgonHugeist
- Zeos Project Manager
- Posts: 1936
- Joined: 31.03.2011, 22:38
Like i wrote you before the patch is done in the testing branches of sf.net. There i've also changed the ftFloat to ftDouble(Extendet-type) because i know about the rounding-problems. You can find the field-arrangements in ZDbcPostrgreUtils.pas...
Best regards, Michael
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/
You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/