IMetabaseUpdateSqlNode.SetDefaultSql

Syntax

SetDefaultSql(Value: String);

Parameters

Value. SQL query text.

Description

The SetDefaultSql method assigns SQL query text used for all DBMS by default.

Comments

Use the IMetabaseUpdateSqlNode.Sql method to assign separate SQL query text for a specified DBMS.

Example

Executing the example requires that the repository contains a table with the OBJ_TABLE identifier and a database with the DB identifier. The schema, 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("OBJ_TABLE");
        DNode.UpdatePart := MetabaseObjectUpdatePart.DataMetadata;
        SQLNode := Root.Add(MetabaseUpdateNodeType.Sql) As IMetabaseUpdateSQLNode;
        SQLNode.Label := "SQL";
        SqlNode.ClearSql;
        SqlNode.SetDefaultSql("Insert Into Log_Table (ACTION,DATE_ACTION) " +
            "Values('Update table Table_1', sysdate) ");
        SqlNode.Database := Db.Key;
        Mu.SaveToFileNF("c:\Update.pefx");
    End Sub UserProc;

After executing the example a new update is created. Data and metadata of the OBJ_TABLE table will be added to the update. An SQL command is also added to update. On executing this SQL command a new record that contains information about the OBJ_TABLE table update is added to the LOG_TABLE table. The SQL command query is executed for all DBMS.

See also:

IMetabaseUpdateSqlNode