IsDatabaseValid: Boolean;
The IsDatabaseValid property returns whether there is a database, to which SQL command executes query in the current repository.
Available values:
True. Database exists in the current repository.
False. DB does not exist in current repository. It is necessary to determine a new DB for SQL command for correct update. One can do it by the IMetabaseUpdateSqlNode.Database or IMetabaseUpdateObjectNode.Object property (the IMetabaseUpdateObjectNode object is returned by the IMetabaseUpdateSqlNode.DatabaseNode property).
NOTE. Before checking if a database exists in the current repository, to which SQL command executes query, it is necessary to check correctness of update. To do this, use the IMetabaseUpdate.Prepare method.
Executing the example requires the update file Update.pef in the root of the C disc. The repository should contain a database with the OBJ_DB identifier.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
Update: IMetabaseUpdate;
UFN: IMetabaseUpdateFolderNode;
i: Integer;
UpdateObj: IMetabaseUpdateSqlNode;
DbNode: IMetabaseUpdateObjectNode;
Begin
MB := MetabaseClass.Active;
Update := Mb.CreateUpdate;
Update.LoadFromFile("C:\Update.pef");
Update.Prepare;
UFN := Update.RootFolder;
For i := 0 To UFN.Count - 1 Do
If UFN.Item(i) Is IMetabaseUpdateSqlNode Then
UpdateObj := UFN.Item(i) As IMetabaseUpdateSqlNode;
If Not UpdateObj.IsDatabaseValid Then
DbNode := UpdateObj.DatabaseNode;
If DbNode <> Null Then
DbNode.Object := MB.ItemById("OBJ_DB");
Else UpdateObj.Database := MB.ItemById("OBJ_DB").Key;
End If;
End If;
End If;
End For;
Update.SaveToFileNF("C:\Update.pefx");
End Sub UserProc;
After executing the example the update C:\Update.pef is opened. For all SQL commands the existence of necessary DB is checked in update. If DB does not exist in the current repository, it will be replaced with the OBJ_DB DB. Changes are saved.
See also: