IMetabaseUpdateSqlNode.Database

Syntax

Database: Integer;

Description

The Database property determines a key of database, SQL query is executed to connect with it.

Comments

If the property is not set, SQL query will be executed for the current repository connection.

Example

Executing the example requires that the repository contains a table with the Table_1 identifier and a database with the DB identifier. The database server, on which this database is set up, contains a table with the LOG_TABLE physical name. This table stores a history of execution of any actions. The table has the ACTION and DATE_ACTION fields that will display action description and date of the occurred action.

Add links to the Db and Metabase system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Db: IMetabaseObject;
    Mu: IMetabaseUpdate;
    Root: IMetabaseUpdateFolderNode;
    SQLNode: IMetabaseUpdateSqlNode;
    DNode: IMetabaseUpdateDataObjectNode;
Begin
    Mb := MetabaseClass.Active;
    Db := Mb.ItemById("DB").Bind;
    Mu := Mb.CreateUpdate;
    Root := Mu.RootFolder;
    DNode := Root.Add(MetabaseUpdateNodeType.DataObject) As IMetabaseUpdateDataObjectNode;
    DNode.Object := MB.ItemById("Table_1");
    DNode.UpdatePart := MetabaseObjectUpdatePart.DataMetadata;
    SQLNode := Root.Add(MetabaseUpdateNodeType.Sql) As IMetabaseUpdateSQLNode;
    SQLNode.Label := "SQL";
    SqlNode.Sql((Db As IDatabase).DriverId) := "Insert Into Log_Table (ACTION,DATE_ACTION) Values('Update the Table_1',sysdate) table";
    SqlNode.IgnoreErrors := True;
    SqlNode.Database := Db.Key;
    Mu.SaveToFileNF("c:\Update.pefx");
End Sub UserProc;

After executing the example a new update is created. The update will include data and metadata of the Table_1 table. An SQL command is also added to update. On executing this SQL command a new record that contains information about the Table_1 table update is added to the Log_Table table. Execution of SQL command will be ignored if it is impossible to add new records to the Log_Table table for some reason. Update will be continued from the next element. The SQL command will be executed within the database server, on which the DB database is set up.

See also:

IMetabaseUpdateSqlNode