Boolean fields in ODAC

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mtawk

Boolean fields in ODAC

Post by mtawk » Tue 11 Jan 2005 08:34

hello,

I'm having a problem in dynamically differentiating boolean fields from integer fields in Oracle.

Usually boolean fields are of type integer(1) in Oracle.
My question is : how can I retreive, using ODAC, the field size from the field type when it is integer(1) ?

Once I can get the size value of the integer type, I can easily differentiate between integer and boolean.

Thanks for your help.

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Tue 11 Jan 2005 14:53

You can use GetDataType, GetFieldScale and GetFieldPrecision methods of your DataSet object to retrieve such info.
For example:

Code: Select all

var
 i : integer;
 FieldName : string;
begin
with OraQuery1 do
  for i := 0 to FieldCount-1 do begin
    FieldName := Fields[i].FieldName;
    if (GetDataType(FieldName) = dtInteger) and (GetFieldScale(FieldName) = 0) and
       (GetFieldPrecision(FieldName) = 1) then
      ;//It's your boolean field
  end;
end;

Post Reply