Page 1 of 1

Using Large Numbers Numeric(18,4)

Posted: Thu 14 Sep 2006 19:48
by ewcarman
Hello All,

I am experimenting with this and have run into an issue.

I need to access a field in an Ora9i table defined as numeric(18,4). ( Using D6, ODAC 5.80 )

I have already turned on the session option EnableNumbers. This allows me to see the number with full precision when accessed with AsString.

However, when accessing it in other ways, the precision is not preserved.

AsFloat - it is subject to the precision of a double. This is expected.

AsCurrency - Format %18.4f
92345678901234.1120

AsBCD - using BCDToStr
92345678901234.112

AsString (which is correct)
92345678901234.1234

If I do the following:

Value: Currency;
Value := StrToCurr(OraQuery1.fieldbyname('verybignum').AsString);
Memo3.Lines.add(format('%18.4f', [Value]));

The precision is preserved.

Is there another means of getting the number from the field as a number?

Best Regards,
Eric

Posted: Fri 15 Sep 2006 10:29
by Plash
The only way to get value of such number without precision loss is using TField.AsString property. AsBCD and AsCurrency properties internally use AsFloat property and then convert value to BCD or Currency.