Retrieving table column names using the Firebird provider

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
thoba
Posts: 4
Joined: Thu 16 Oct 2008 09:29

Retrieving table column names using the Firebird provider

Post by thoba » Thu 16 Oct 2008 09:41

Hi,

I'm trying to retrieve the column names of a specified table from a Firebird 2.0.4 database (embedded) using UniDAC 1.2 under D2007. The code I write is:

LMetaData := TUniMetaData(IConnection.CreateMetaData);
try
LMetaData.MetaDataKind := 'Columns';
LMetaData.Restrictions.Values['TABLE_NAME'] := TableName;
LMetaData.Open;
LMetaData.GetMetaDataKinds(AList);
finally
LMetaData.Free;
end;

... however, the result in AList is not the column names from the table but instead the list is filled with all available MetaDataKind restrictions (Columns, Constraints, IndexColumns, ... ). Am I doing something wrong or is this a bug?

Many thanks in advance for your help.

Best regards,

/T

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

Post by Plash » Fri 17 Oct 2008 11:05

The GetMetaDataKinds procedure returns metadata kinds that are supported by TUniMetaData.

To get the column names, you can use the TUniMetaData component like TUniQuery:

Code: Select all

LMetaData.Open;
while not LMetaData.Eof do begin
  ColName := LMetaData.FieldByName('COLUMN_NAME').AsString;
  LMetaData.Next;
end;

thoba
Posts: 4
Joined: Thu 16 Oct 2008 09:29

Post by thoba » Fri 17 Oct 2008 13:18

Many thanks, works just fine !! /T

Post Reply