#1 Re: mORMot 1 » Newbie Using Batch commands » 2016-02-17 12:33:36

Dear Ab,

Thank you for the quick reponse and fantastic framework.

ab wrote:

Workaround may be to create all slave instances in a first BATCH, then create the master instances in a second BATCH.

This is my current method. Doing it this way enables me to delete the slave (detail) records if the second BATCH fails for some reason.

ab wrote:

We may add a feature at TSQLRestBatch level to make the whole process in a single step, e.g. by adding a new TSQLRestBatch.AddDetail() method, which would fill the column ID during the BATCH execution...
But it is not implemented yet.

In my book, this will fill a current gap in Client side BATCH processing (recommended) as I saw from the documentation, Transactions are not good to use on Client side when multiple client access is anticipated.

Hope to see this feature soon ... roll

#2 mORMot 1 » Newbie Using Batch commands » 2016-02-17 07:15:40

deonbez
Replies: 2

Dear All (and Ab),

How do I alter the example code below (as from documentation) to use client side batch commands (BatchStart, BatchAdd and BacthSend)?
I do not know how to get the IDs for instances One and Two in batch mode, because IDs only become available as part of the BatchSend results.

begin 
   One := TSQLMyFileInfo.Create; 
   Two := TSQLMyFileInfo.Create; 
   MyFile := TSQLMyFile.Create; 
   try 
      One.MyFileDate := .... 
      One.MyFileSize := ... 
      MyFile.FirstOne := TSQLMyFileInfo(MyDataBase.Add(One,True)); // add One and store ID in MyFile.FirstOne 
      Two.MyFileDate := .... 
      Two.MyFileSize := ... 
      MyFile.SecondOne:= TSQLMyFileInfo(MyDataBase.Add(Two,True)); // add Two and store ID in MyFile.SecondOne 
      MyDataBase.Add(MyFile,true); 
   finally 
     MyFile.Free; 
     Two.Free; 
     One.Free; 
   end; 
end;

Board footer

Powered by FluxBB