ODAC

TOraSession.AutoCommit Property

Used to permit or prevent permanent updates, insertions, and deletions of data associated with the current transaction against the database server.

Class

TOraSession

Syntax

property AutoCommit: boolean;

Remarks

Use the AutoCommit property to permit or prevent permanent updates, insertions, and deletions of data associated with the current transaction against the database server without explicit calls to the Commit or Rollback methods.

Set AutoCommit to True to permit implicit call to Commit method after every database access.

AutoCommit property in TOraSession has higher precedence over the same properties in dataset components. Its default value is True.

Note: The AutoCommit property in TOraSesion globally specifies whether all queries to modify a database are implicitly committed or not. Components which descend from the TCustomDADataSet and TCustomDASQL classes inherit their AutoCommit properties. This allows them to specify their implicit transaction selectively committing the behavior after each data modifying access.

This is an example of procedure that removes all records from Dept table and makes this change permanent.

Example

procedure TForm1.DeleteClick(Sender: TObject);
begin
   OraSQL.Session := OraSession;
   OraSession.AutoCommit := True;
   OraSQL.AutoCommit := False;
   OraSQL.SQL := 'DELETE FROM Dept'; 
   OraSQL.Execute;         // delete all records, commit is not performed
   OraSession.Rollback;// restore deleted records 
   OraSession.AutoCommit := False;
   OraSQL.AutoCommit := True;
   OraSQL.SQL := 'DELETE FROM Dept'; 
   OraSQL.Execute;         // delete all records, commit is not performed
   OraSession.Rollback; // restore deleted records 
   OraSession.AutoCommit := True;
   OraSQL.AutoCommit := True;
   OraSQL.SQL := 'DELETE FROM Dept'; 
   OraSQL.Execute;         // delete all records, commit is performed
   OraSession.Rollback; // couldn't restore deleted records 
end; 

See Also

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback