Using Large Numbers Numeric(18,4)

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ewcarman
Posts: 1
Joined: Thu 14 Sep 2006 19:34

Using Large Numbers Numeric(18,4)

Post by ewcarman » Thu 14 Sep 2006 19:48

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 15 Sep 2006 10:29

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.

Post Reply