AnyDAC
ContentsIndexHome
PreviousUpNext
Metadata Questions

The list of questions and answers related to the metadata retrieval.

Group
Links
QT1: Is there any method to check if table exist inside DB?

A: There are two basic methods: 

 

1)

try
  ADQuery1.Open('select * from tab where 0 = 1');
  Result := True;
except
  on E: EADDBEngineException do
    if E.Kind = ekObjNotExists then
      Result := False
    else
      raise;
end;

 

2)

var
  oList: TStrings;
begin
  oList := TStringList.Create;
  try
    GetTableNames('', '', ATableName, oList, [osMy, osOther, osSystem],
      [tkTable, tkTempTable, tkLocalTable]);
    Result := oList.Count > 0;
  finally
    oList.Free;
  end;
end;

 

The first one is more optimal. 

 

QT2: For oracle, is it possible to get the package procedures using the TADMetaInfoQuery ?

A: The following code returns a list of procedures for the PACKAGE_NAME Oracle package. 

 

ADMetaInfoQuery1.BaseObjectName := 'PACKAGE_NAME';
ADMetaInfoQuery1.MetaInfoKind := mkProcs;
ADMetaInfoQuery1.Open;

 

QT3: How to get index names using the TADMetaInfoQuery ?

A: The following code returns a list of indexes for the MY_TAB table. 

 

ADMetaInfoQuery1.ObjectName := 'MY_TAB';
ADMetaInfoQuery1.MetaInfoKind := mkIndexes;
ADMetaInfoQuery1.Open;

 

QT4: Query Builder, design-time editors and metadata retrieval functions return object names belonging to my current schema, prefixed with schema / catalog name. How to exclude it ?

A: AnyDAC has two general connection definition parameters - MetaDefCatalog and MetaDefSchema. Depending on DBMS either or both of them are supported (see AnyDAC Database Connectivity for details). If object belongs to a specified MetaDefCatalog catalog / MetaDefSchema schema, then this catalog / schema name will be excluded from an object name. So, set MetaDefCatalog / MetaDefSchema to your development catalog / schema name, if you need to deploy your application to different catalog / schema. 

 

QT5: I am calling Oracle stored procedure using public synonym, but AnyDAC always appends schema name to stored proc name. How to avoid that ?

A: AnyDAC has two general connection definition parameters - MetaCurCatalog and MetaCurSchema. Depending on DBMS either or both of them are supported (see AnyDAC Database Connectivity for details). Setting them to '*' will avoid usage of a corresponding name part in a full object name.

What do you think about this topic? Send feedback!