3

I looking for get metadata on a TFDQuery (FireDAC).

I have this query:

SELECT * 
FROM Table1 t1 
INNER JOIN Table2 t2 ON t1.Code = t2.code

I would like to know the column information (table name, the real column name in the table, ....)

I find this post : How to get the table name from a field in a join query with MSSQL? (mysql_field_table equivalent) but I have not the same structure on FireDac.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Joc02
  • 345
  • 8
  • 18
  • I think you will need to fetch meta data as well. I can try to check this out later. – Victoria Aug 01 '17 at 13:38
  • 1
    Take a look at http://docwiki.embarcadero.com/RADStudio/XE8/en/Extended_Metadata_(FireDAC) and http://docwiki.embarcadero.com/RADStudio/XE8/en/Working_with_Metadata_(FireDAC) – RBA Aug 01 '17 at 13:59
  • @RBA, yep, I meant these (they are called extended meta data, not just meta data) :) – Victoria Aug 01 '17 at 14:09

1 Answers1

2

As RBA already mentioned you have to enable ExtendedMetaData in the connection first. When done you can get the field column description via query.GetFieldColumn(field) and access the table and column name with its ActualOriginTabName and ActualOriginColName properties.

column := query.GetFieldColumn(field);
orgTableName := column.ActualOriginTabName;
orgColumnName := column.ActualOriginColName;
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130