Field metadata

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mariusz
Posts: 62
Joined: Wed 16 Jul 2008 21:04
Location: Poland / Poznan
Contact:

Field metadata

Post by mariusz » Tue 21 May 2013 19:50

Hi... I have question...

I'm going to create some universal forms that feeds them selves with information from field metadata from database. Because my application connects to database through Internet and that connection are not reliable, I wouldn't like to send to many sql to database asking for data from rdb$tables.

My question is... is there any place that I can get information like field description / domain / null/not_null flag from?

regards
Mario

AndreyZ

Re: Field metadata

Post by AndreyZ » Wed 22 May 2013 07:33

Hello,

You can obtain information about domain names and nullable flags from the TIBCFieldDesc class. Here is a code example:

Code: Select all

begin
  IBCQuery1.Options.RequiredFields := True;
  IBCQuery1.Options.SetDomainNames := True;
  IBCQuery1.SQL.Text := 'select * from testdomains';
  IBCQuery1.Open;
  ShowMessage(TIBCFieldDesc(IBCQuery1.GetFieldDesc('id')).DomainName);
  ShowMessage(BoolToStr(TIBCFieldDesc(IBCQuery1.GetFieldDesc('id')).Required, True));
  ShowMessage(TIBCFieldDesc(IBCQuery1.GetFieldDesc('name')).DomainName);
  ShowMessage(BoolToStr(TIBCFieldDesc(IBCQuery1.GetFieldDesc('name')).Required, True));
end;
Note that to run this code, you should add the IBCClasses unit to the USES clause of your unit.
The testdomains table is the following table:

Code: Select all

CREATE TABLE TESTDOMAINS (
    ID    TESTDM PRIMARY KEY,
    NAME  VARCHAR(20)
);
, and TESTDM is the following domain:

Code: Select all

CREATE DOMAIN TESTDM AS INTEGER;
You can also use the TIBCMetaData component to obtain different kinds of meta-information from the server. For more information, please read the IBDAC documentation.

Post Reply