use of savepoints

sadkat

Member
Hello,
I'm trying to use the savepoints in delphi 5 that way:
1) when the event form1.onshow ocurrs execute the line datamodule2.OracleSession1.Savepoint('s');
2) let the user do inserts & posts on a table
3) when the user closes the form, execute the following lines:

if messagedlg('confirm new records?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
datamodule2.OracleSession1.Commit;
else
datamodule2.oraclesession1.
RollbackToSavepoint('s');

and an error ocurred:
ORA-01086: Savepoint 'S' never established

how do i have to use correctly the savepoints?
 
By default the TOracleDataSet will implicitly commit each posted record, so your savepoint is gone after the first record is posted. To achieve the functionality you describe, you need to use cached updates (TOracleDataSet.CachedUpdates = True). Now all posted records are stored in a local change log, allowing you to apply all changes (TOracleSession.ApplyUpdates) or none (TOracleSession.CancelUpdates).

------------------
Marco Kalter
Allround Automations
 
Setting at design-time the 'CommitOnPost' property to FALSE of the TOracleDataSet wouldn't be a fast solution ?

------------------

[This message has been edited by MYTSKIDIS GEORGIOS (edited 18 May 2001).]
 
Not really. Cached Updates can be cancelled and retried, because the dataset keeps track of the changes that are applied to the database. If you use the CommitOnPost property, the only change is that things are not committed. You cannot cancel or retry these changes though.

------------------
Marco Kalter
Allround Automations
 
Back
Top