Problems with saving a BCD with more than 4 decimal places using TClientdatasets

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Guest

Problems with saving a BCD with more than 4 decimal places using TClientdatasets

Post by Guest » Thu 17 Mar 2005 12:28

Hi

I'm currently using the dbExpress driver for MS SQL Server 2.00 with Delphi v6.

I'm trying to save a decimal value with more that 4 decimal places to a SQL Server 2000 table.

The field is declared as

Unit_Charge DECIMAL 19,10

in the SQL Server 2000 table.

I can seem to successfully get the value of the Unit_Charge into the TClientdataset with more than 4 decimal places by
using aABcd when assigning the value (and using variants to successfully convert from EXTENDED to BCD)

eg
-------------------------------------------------------------------------------------------------------------------------------------------------
{ This function is used for preserving more than 4 decimal places on a bcd value. This
is needed because using AsCurrency or AsFloat seems to only preserve a maximum of 4... }
function CIL_ExtendedToBCD(ManyDecPlacesNum: Extended): TBcd;
begin
{ Will return a number with up to 123456789.1234567890... }
Result := VarToBCD(VarFmtBCDCreate(ManyDecPlacesNum,19,10));
end;

{ Used for assigning the value to the clientdataset... }
cdsInvDetailUNIT_CHARGE.AsBcd := CIL_ExtendedToBCD(Unit_Charge);
-------------------------------------------------------------------------------------------------------------------------------------------------
After inspecting this value after a POST this value was still correct on the TClientDataSet. However after using ApplyUpdates on the TClientDataSet the value is only save as 4 decimal places in the SQL Server table.

eg

47.143433434 (in the Client Dataset TFMTBCDField field prior to ApplyUpdates)

but stored as 47.1434 in the SQL Server 2000 table

Is this a known problem? Are there any work arounds?

Thanks for your help.

Stefan Fiorentini

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 18 Mar 2005 14:33

Thank you for information.
It's known problem and we've already fixed it. Fix will be included in the next DbxSda build. It will be available in about one weeks.

Post Reply