#1 2015-12-29 20:19:21

ramersonw
Member
From: Brazil
Registered: 2015-07-16
Posts: 6

Doubt about Transactions

Hi all,
It could be a noob question, but I have some doubts about transactions management in Mormot...
Say I have this situation: 3 TSQLRecords inside a function and if one of them returns a error, all the others have to rollback.

pseudo-code:

procedure Save;
var
  obj1: TPerson;  // 
  obj2: TAddress; // All TSQLRecord
  obj3: TPhones; //
begin
  startTransaction;
  try
    obj1.name := 'test1';
    TSQLRest.Add(obj1);

    obj2.Address := 'Street1';
    TSQLRest.Add(obj2);  //----> Say I have an error here

    obj3.phone := '65432';
    TSQLRest.Add(obj3);

    Commit;
  except
    RollBack;
  end;
end;

How would I implement the above situation in Mormot?

I saw some functions for transactions control, but inside batch methods. They control only for 1 object with multiple records.

Thanks in advance.

Offline

#2 2015-12-29 21:17:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Doubt about Transactions

Use the batch methods, with automatic transaction.

Otherwise you may encounter unexpected race conditions when manual blocking transactions are used from client side.

OR use a SOA service and a short non blocking transaction on server side.

Offline

Board footer

Powered by FluxBB