Commit problem

Olegus

Member
I need to commit multiple changes at once.
For example I have next code:
Code:
procedure save(data:Tmydata);
begin
  case data.state of
    dsInsert: insertdata(data);
    dsUpdate: updatedata(data);
    dsdelete: deleteData(data);
  end;
  session.commit;
end;
I have a tree.
I call Save method for each node but I must commit or rollback changes for WHOLE tree.
Code above doesn't work . It seems , session.commit commits something else- I lose my changes , that I made in insertdata, deletedata and updatedata.
I use spInternal pooling.
It looks like those SQLs executes in different sessions.
Generally, how can I achieve such logic? I am pretty sure- it is common case.

[This message has been edited by Olegus (edited 19 March 2002).]

[This message has been edited by Olegus (edited 19 March 2002).]
 
Ups, I wrote wrong code above.
The Idea is to do updates in recursive method till finish all tree.
Read it as follwows:
Code:
Procedure Save(Tree:TmyTreeData);
begin
  saveTreeRecursive(Tree);
  session.submit;
end;

Procedure saveTreeRecursive(Data:TmyTreeData);
begin
  case data.state of
    dsInsert: insertdata(data);
    dsUpdate: updatedata(data);
    dsdelete: deleteData(data);
  end;
  if not lastlevel then
   saveTreeRecursive(Subtree:TmyTreeData);
end;
 
If the Session that you commit is the same as the Session of the components (TOracleQuery, TOracleDataSet?) that you use to insert, update or delete the data, then it must work. If you are using a TOracleDataSet then CommitOnPost and CachedUpdates must be False.

------------------
Marco Kalter
Allround Automations
 
How can I be sure that I have right session?
It is multiuser environment and I use session spInternal pooling . It seems I cannot manage this. My insert can executes under one session and my delete can use another one.
Only the idea I have- to declare and to open new TOracleQuery and new TOracleSession in my Save method. I don't like it. Is there the way to identify session by handler or somehow else and to use exactly this one?
 
Back
Top