Page 1 of 1

Retrieving table column names using the Firebird provider

Posted: Thu 16 Oct 2008 09:41
by thoba
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

Posted: Fri 17 Oct 2008 11:05
by Plash
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;

Posted: Fri 17 Oct 2008 13:18
by thoba
Many thanks, works just fine !! /T