Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Apply multiple dataset updates in one transaction


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0 Threads: [ Previous | Next ]
Anders Gustavsson

Posts: 26
Registered: 9/26/99
Apply multiple dataset updates in one transaction  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 6, 2016 11:59 PM
A long time ago I used code from Dan Miser's Midess package (https://sourceforge.net/projects/midess/) to implement cached updates for Paradox and later for NexusDB. Up to now the different layers have been kept together in one executable, so it was easy to let things mix up more than strict rules should really allow.

I am now in the process of upgrading to MS SQL implementing the data access layer with FireDAC, but I would like to keep what I have in the ClientDataset layer. AND I would like to make a clean cut between these two layers, maybe even making it possible to have them in separate applications.

So here is the problem, the central piece of the Midess data applying code:

procedure CDSApplyUpdates(ADatabase : TDatabase; var vDeltaArray: OleVariant; const vProviderArray: OleVariant; Local: Boolean);
var
  i : integer;
  LowArr, HighArr: integer;
  P: PArrayData;
begin
  {Wrap the updates in a transaction. If any step results in an error, raise}
  {an exception, which will Rollback the transaction.}
  ADatabase.Connected:=true;
  ADatabase.StartTransaction;
  try
    LowArr:=VarArrayLowBound(vDeltaArray,1);
    HighArr:=VarArrayHighBound(vDeltaArray,1);
    P:=VarArrayLock(vDeltaArray);
    try
      for i:=LowArr to HighArr do
        ApplyDelta(vProviderArray, P^, Local);
    finally
      VarArrayUnlock(vDeltaArray);
    end;
    ADatabase.Commit;
  except
    ADatabase.Rollback;
  end;
end;


The vDeltaArray are the deltas from the updated clientdatasets. The vProviderArray is an array with information about the providers involved. Those two originate from the clientside application. But the transaction code for the ADatabase belongs to the serverside.

So what I would need is a way to send the vDeltaArray and the vProviderArray (and maybe a few other things too) from the one side to the other. My plan is to do it with the use of a DataSnap server. I have tried to pass the OleVariants but I keep getting errors like unknown datatypes and so on, and I can't figure out how to do it properly.

Any help would be appreciated. Even ideas of how to solve this with different scenarios are welcome, but as there are quite a lot of clientdataset logic to rebuild, really good arguments in their favour are needed :-)

Anders
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02