Rollback;
The Rollback method cancels the changes made within this transaction.
Sub UserProc;
Var
Driver: IDalDriver;
Connect: IDalConnection;
Command: IDalCommand;
ConnectDesc: IDalConnectionDescriptor;
ConnectDescParams: IDalConnectionDescriptorParams;
Begin
Driver := New DalOrcl8Driver.Create;
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 rollback of changes
Connect.Rollback;
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. Then made changes are canceled.
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 Sub UserProc();
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 rollback of changes
Connect.Rollback();
Command.Close();
Connect.Close();
End Sub;
See also: