Android Question jrdc2 executeQuery .vs. executeBatch

OliverA

Expert
Licensed User
Longtime User
ExecuteQuery: A single query statement (SELECT). Only one pre-defined (configured on the server) SELECT statement can be sent to the jRDC2 server at a time. No exceptions.

ExecuteBatch: 1 or more pre-defined non-query statements (INSERT, UPDATE, DELETE) can be sent to the jRDC2 server. If, for example, you have 100 INSERT statements, you can create all 100 statements and then sent them all at once to the jRDC2 server.

Look here: https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/. The GetRecord method can only sent one "select_animal" command to the jRDC2 server at once to retrieve an animal. The InsertRecord, on the other hand, could be rewritten as:
B4X:
Sub InsertRecords (Names() As String)
   Dim cmdList as List
   cmdList.Initialize
   For Each Name as String in Names
      Dim cmd as DBCommand = CreateCommand("insert_animal", Array(Name, Null))
      cmdList.Add(cmd)
   Next
   Dim j As HttpJob = CreateRequest.ExecuteBatch(cmdList, Null)
   Wait For(j) JobDone(j As HttpJob)
   If j.Success Then
       Log("Inserted successfully!")
   End If
   j.Release
End Sub
As you can see, only one ExecuteBatch is called for all the insert commands created.
 
Upvote 0
Top