How do I prevent TOraSession from implicit commit?
How do I prevent TOraSession from implicit commit?
If an application is stopped or crashes while TOraSession is in transaction
DML changes are saved anyway.Is there a way to prevent TOraSession
from committing these changes ? Both TOraSession and TOraTable AutoCommit properties are set to false.
I can see the same topic, but can't see the answer.
DML changes are saved anyway.Is there a way to prevent TOraSession
from committing these changes ? Both TOraSession and TOraTable AutoCommit properties are set to false.
I can see the same topic, but can't see the answer.
Hi,
In your last answer in the following link you seem to have an other solution ?
http://www.devart.com/forums/viewtopic. ... t=implicit
Thanks,
In your last answer in the following link you seem to have an other solution ?
http://www.devart.com/forums/viewtopic. ... t=implicit
Thanks,
Hello Alexp,
I have no problem with TOraTransaction.DefaultCloseAction defaults to taRollback.
I think that if TOraSession.AutoCommit=False and it manages the transaction (TOraSession.StartTransaction without TOraTransaction) it should not save changes to the database before TOraSession.Commit command.
I have no problem with TOraTransaction.DefaultCloseAction defaults to taRollback.
I think that if TOraSession.AutoCommit=False and it manages the transaction (TOraSession.StartTransaction without TOraTransaction) it should not save changes to the database before TOraSession.Commit command.
Hello,
The AutoCommit property is responsible for the “immediate” commit of data into a table, i.e. if this property is on, it will be impossible to perform rollback after executing the following code:
If transaction is started explicitly
the AutoCommit property does not influence saving data, and data is saved to the server only on the explicit calling of
, on closing a session with an active transaction, or on destroying a component (in two latter cases the TOraTransaction.DefaultCloseAction property should be set to taCommit).
The AutoCommit property is responsible for the “immediate” commit of data into a table, i.e. if this property is on, it will be impossible to perform rollback after executing the following code:
Code: Select all
OraSQL.SQL := 'DELETE FROM Dept';
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 Code: Select all
OraSession.StartTransaction Code: Select all
OraSession.CommitHello,
By using the (Ctr+Alt+Del) you can end a task in the following two ways:
1- End Task
2- End Process
In the first case, the application will close on getting the WM_CLOSE, and its data will be committed. The second option is equivalent to application crash, data will not be committed.
In order not to add TOraTransaction to each TOraSession component, you can use your own component inherited from ToraSession, as I wrote earlier.
By using the (Ctr+Alt+Del) you can end a task in the following two ways:
1- End Task
2- End Process
In the first case, the application will close on getting the WM_CLOSE, and its data will be committed. The second option is equivalent to application crash, data will not be committed.
In order not to add TOraTransaction to each TOraSession component, you can use your own component inherited from ToraSession, as I wrote earlier.
Hello,
You wrote earlier "Create a descendant of TOraSession and change the DefaultTransaction.DefaultCloseAction property to taRollback".
I don't have the source yet.Do you say thay I should create a TOraTransaction component inside the TOraSession descendant or is there a built in privete/protected DefaultTransaction property?
You wrote earlier "Create a descendant of TOraSession and change the DefaultTransaction.DefaultCloseAction property to taRollback".
I don't have the source yet.Do you say thay I should create a TOraTransaction component inside the TOraSession descendant or is there a built in privete/protected DefaultTransaction property?
Hello,
To prevent data from being automatically committed, you need to override the TOraSession constructor by setting the DefaultTransaction.DefaultCloseAction property to taRollback. The component's code is provided below:
To prevent data from being automatically committed, you need to override the TOraSession constructor by setting the DefaultTransaction.DefaultCloseAction property to taRollback. The component's code is provided below:
Code: Select all
unit RollbackOraSession;
interface
uses
SysUtils, Classes, DB, DBAccess, Ora, CRAccess;
type
TRollbackOraSession = class(TOraSession)
public
{ Public declarations }
constructor create(Owner: TComponent);override;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Oracle Access', [TRollbackOraSession]);
end;
{ TRollbackOraSession }
constructor TRollbackOraSession.create(Owner: TComponent);
begin
inherited create(Owner);
DefaultTransaction.DefaultCloseAction := taRollback;
end;
end.