#1 2016-02-17 07:15:40

deonbez
Member
From: South Africa
Registered: 2016-02-17
Posts: 2

Newbie Using Batch commands

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;

Offline

#2 2016-02-17 09:59:09

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

Re: Newbie Using Batch commands

The generated IDs are indeed not known before the BATCH returns.

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

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.

Offline

#3 2016-02-17 12:33:36

deonbez
Member
From: South Africa
Registered: 2016-02-17
Posts: 2

Re: Newbie Using Batch commands

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

Offline

Board footer

Powered by FluxBB