IMetabaseUpdateSqlNode.IsDatabaseValid

Fore Syntax

IsDatabaseValid: Boolean;

Fore.NET Syntax

IsDatabaseValid: boolean;

Description

The IsDatabaseValid property returns whether there is a database, to which SQL operator executes query in the current repository.

Comments

The property is read-only.

Available values:

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.

Fore Example

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.

Fore.NET Example

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:

IMetabaseUpdateSqlNode