Hi,
we treat such fields as integers if they can be put to it:
else if (aDataType = 'decimal') or (aDataType = 'numeric') then begin
if (ADecScale = 0) and (ADecPrec < 19) then begin
case ADecPrec of
0: result := datFloat;
1,2: result := datShortInt;
3,4: result := datSmallInt;
5..9: result := datInteger;
else
result := datLargeInt;
end;
end
else
result := datDecimal
but in your case, we can’t guarantee that data won’t be lost so we use Decimal
.
we have these methods in uROBinaryHelpers
unit that work with Decimal
:
function BCDToDecimal(const aBcd: TBcd): TDecimal;
function DecimalToBCD(const aDecimal: TDecimal): TBcd;
function DecimalToString(const aDecimal: TDecimal; aDot: Char): string;
function StringToDecimal(const aString: string; aDot: Char): TDecimal;
function DecimalToVariant(const aDecimal: TDecimal): Variant;
function VariantToDecimal(const aVariant: Variant): TDecimal;
function VariantToBCD(const aVariant: Variant): TBCD;
function BCDToVariant(const aBCD: TBCD; const StoreAsDecimal: Boolean = False): Variant;
// correctly convert DecimalVariant into string
function DecimalVariantToString(const aVariant: Variant): string;
{ ToDo: extend this to handle all common Variant types, and use it for
marshaling OwnerData, instead of string. }
in your case, I can suggest to use something like
integer_value := BcdToInteger(VariantToBCD(field.value));
currency_value := BcdToCurr(VariantToBCD(field.value));
float_value := BcdToDouble(VariantToBCD(field.value));
string_value := DecimalVariantToString(field.value);
Edit: if you change declaration of such fields in schema as Integer and Float, these fields will be as you defined them