Float, Integer, Largeint and Numbers

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
easyblue
Posts: 64
Joined: Wed 02 Feb 2005 13:02
Location: Shanghai

Float, Integer, Largeint and Numbers

Post by easyblue » Tue 14 Dec 2010 01:43

Hello

ODAC 6.90.0.60+BDS2006

I am struggling in mapping of data among Float, Integer, LargeInt and Numbers, and always failed.

Image following Query:

select 1 as f1,
1.22 as f2,
1234567 as f3,
12345678901234567 as f4,
123456789012345678 as f5
from dual

And I expect that f1 be mapped into an Integer type, f2 for float, f3 for integer, f4 for integer, f5 for Largeint.


if I have set in the Orasession.Options as
EnableIntegers:=True;
EnableLargeint:=True;
EnableNumbers:=True;

Result: All files are mapped into ftNumbers.

if I set:
EnableIntegers:=True;
EnableLargeint:=True;
EnableNumbers:=False

then all the fields are mapped to ftFloat

It seems that the three Precisions:
IntegerPrecision,
LargeIntPrecision,
FloatPrecision

does not work?

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Tue 14 Dec 2010 10:47

Hello

Oracle returns precision for all columns equal to 38. Any integer number with precision = 38 cannot be stored in the Delphi Integer type because it has size 32 bit. So ODAC creates TFloatFields for these columns. But you can change this behavior by defining SmallintPrecision, IntegerPrecision or LargeIntPrecision global variables in the OraClasses unit.

The sample:

Code: Select all

begin
  LargeIntPrecision := 38;

  OraQuery1.SQL.Text := 'select 1 as f1, ' + #13 +
                        '1.22 as f2, ' + #13 +
                        '1234567 as f3, ' + #13 +
                        '12345678901234567 as f4, ' + #13 +
                        '123456789012345678 as f5 ' + #13 +
                        'from dual ';
  OraQuery1.Open;

  Memo1.Clear;
  for i := 0 to OraQuery1.FieldCount - 1 do
    Memo1.Lines.Add(OraQuery1.Fields[i].ClassName);
end;
In this sample all fields will be created as TLargeIntField.

Post Reply