Commit;
The Commit method saves made changes within this transaction.
To initialize transaction, first execute the IDalConnection.StartTransaction method.
Sub UserProc;
Var
Driver: IDalDriver;
Connect: IDalConnection;
Command: IDalCommand;
ConnectDesc: IDalConnectionDescriptor;
ConnectDescParams: IDalConnectionDescriptorParams;
Begin
Driver := New DalOrcl8Driver.Create;
//Connection parameters
ConnectDesc := Driver.CreateDescriptor;
ConnectDescParams := ConnectDesc.Params;
ConnectDescParams.Find("User Name").Value := "User";
ConnectDescParams.Find("Password").Value := "Password";
ConnectDescParams.Find("Host BSTR").Value := "OrclServer";
ConnectDescParams.Find("Schema").Value := "Repository";
//Create a connection
Connect := ConnectDesc.CreateConnection;
Command := Connect.CreateCommand;
//Command
Command.SQL := "Insert Into DataTable Values ('AA','BB',11,22,'12.12.2008')";
Connect.StartTransaction;
//Execute command
Command.Execute;
//Finish transaction with data saving
Connect.Commit;
Command.Close;
Connect.Close;
End Sub UserProc;
On executing the example the repository connection is established with specified location parameters. After that the transaction is initialized, and the SQL query is executed, a new record is added to the DataTable table.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.PiLibNet.Utils;
Public Shared Sub Main(Params: StartParams);
Var
Driver: DalOrcl8Driver = ComCreator.Instance.CoCreate<DalOrcl8DriverClass>();
Connect: IDalConnection;
Command: IDalCommand;
ConnectDesc: IDalConnectionDescriptor;
ConnectDescParams: IDalConnectionDescriptorParams;
Begin
ConnectDesc := Driver.CreateDescriptor();
//Connection parameters
ConnectDescParams := ConnectDesc.Params;
ConnectDescParams.Find("User Name").Value := "User";
ConnectDescParams.Find("Password").Value := "Password";
ConnectDescParams.Find("Host BSTR").Value := "OrclServer";
ConnectDescParams.Find("Schema").Value := "Repository";
//Create a connection
Connect := ConnectDesc.CreateConnection();
Command := Connect.CreateCommand();
//Command
Command.SQL := "Insert Into DataTable Values ('AA','BB',11,22,'12.12.2008')";
Connect.StartTransaction();
//Execute command
Command.Execute();
//Finish transaction with data saving
Connect.Commit();
Command.Close();
Connect.Close();
End Sub;
See also: