How can I find the true database field type

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

How can I find the true database field type

Post by sinys » Sat 01 Sep 2012 06:56

How can I find the true database field type?

db type | visible type in grid
long -> memo
long raw -> blob
nclob -> hugeclob
raw -> varbytes

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

Re: How can I find the true database field type

Post by bork » Mon 03 Sep 2012 10:14

Hello

What does it mean "true database field type"? Can you explain this term more detailed?

To get field classes in the run-time you can use the following code:

Code: Select all

var
  i: integer;
begin
  OraQuery1.Open;
  for i := 0 to OraQuery1.FieldCount - 1 do
    ShowMessage('FieldName  = ' + OraQuery1.Fields[i].FieldName + #13 +
                'FieldClass = ' + OraQuery1.Fields[i].ClassName);
end;

sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Re: How can I find the true database field type

Post by sinys » Wed 05 Sep 2012 07:28

Code: Select all

create table TEMP1
(
  a LONG RAW,
  b BLOB,
  c CLOB,
  d NCLOB
);
/

select * from TEMP1
In DBGrid I see (blob), (hugeblob), (hugeclob) and (hugeclob)
how I can find in OraQuery what "A" it is LONG RAW in db and "B" it is BLOB in db and how to distinguish "c" and "d" datatypes in ODAC (CLOB and NCLOB)?

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

Re: How can I find the true database field type

Post by bork » Wed 05 Sep 2012 14:08

To get real DB field types you can use the TOraMetaData component:

Code: Select all

begin
  OraMetaData1.MetaDataKind := 'Columns';
  OraMetaData1.Restrictions.Clear;
  OraMetaData1.Restrictions.Add('TABLE_NAME=TEMP1');
  OraMetaData1.Open;
end;

Post Reply