IsDatabaseValid: Boolean;
IsDatabaseValid: boolean;
The IsDatabaseValid property returns whether there is a database, to which SQL operator executes query in the current repository.
The property is read-only.
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 operator for a correct update execution. The user can do it with the help of the IMetabaseUpdateSqlNode.Database or IMetabaseUpdateObjectNode.Object property (the IMetabaseUpdateObjectNode object returns the IMetabaseUpdateSqlNode.DatabaseNode property).
NOTE. Before checking if a database exists in the current repository, to which SQL operator executes query, it is necessary to correctness of update. Use the IMetabaseUpdate.Prepare method to do this.
Executing the example requires the update file C:\Update.pef. The repository must 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 this example the update C:\Update.pef is opened. For all SQL operators the existence of necessary DB is checked in update. If DB does not exist in current repository, it will be substituted with DB OBJ_DB. Changes are saved.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
Update: IMetabaseUpdate;
UFN: IMetabaseUpdateFolderNode;
i: Integer;
UpdateObj: IMetabaseUpdateSqlNode;
DbNode: IMetabaseUpdateObjectNode;
Begin
MB := Params.Metabase;
Update := Mb.CreateUpdate();
Update.LoadFromFileNF("C:\" + "Update.pef", UpdateLoadMode.ulmInsertUpdate);
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;
See also: