IConnectionTransaction.Commit

Fore Syntax

Commit;

Fore.NET Syntax

Commit();

Description

The Commit method saves all changes on the database server and finishes transaction.

Comments

When slice data is saved, which data source is a standard cube, the saving is executed within the external transaction.

Fore Example

Sub Main;
Var
   MB: IMetabase;
    DB: IDatabaseInstance;
    Connect: ISecurityConnection;
    Command: IDalCommand;
    Tran: IConnectionTransaction;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("BD").Open(NullAs IDatabaseInstance;
    Connect := DB.Connection;
    Command := Connect.CreateCommand("Insert Into Table_1 values ('A',1)");
    Tran := Connect.StartTransaction(False);
Try
    Command.Execute;
    Tran.Commit;
Except
    Tran.Rollback;
End Try;
    Command.Close;
End Sub Main;

After executing the example connection to the DB server, on which the BD repository database is set, is performed. SQL query that inserts a new record in a table with the Table_1 physical name is created and executed for this connection. If there is any unsaved data, it is saved on the server.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Db;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Connect: ISecurityConnection;
    Command: IDalCommand;
    Tran: IConnectionTransaction;    
Begin
    MB := Params.Metabase;
    DB := MB.ItemById["BD"].Open(NullAs IDatabaseInstance;
    Connect := DB.Connection;
    Command := Connect.CreateCommand("Insert Into Table_1 values ('A',1)");
    Tran := Connect.StartTransaction(False);
Try
    Command.Execute();
    Tran.Commit();
Except
    Tran.Rollback();
End Try;
    Command.Close();
End Sub;

See also:

IConnectionTransaction