Android Question ExecuteBatch how to use

Tom1s

Member
Licensed User
Longtime User
Hi

I would like to upload all the rows from the sqllite table to the server.
I think it would be best to use execute batch but I can't figure out the way to do it.

If cmd name is "i" & i ' should I put RDC config file the same
sql.?i=INSERT INTO table 1 (col1,col2) VALUES (?,?) ?

B4X:
Dim i As Int
Dim commands As List
commands.Initialize
CursorLog = SQL1.ExecQuery("Select col1,col2 from Table1")

For i = 0 To CursorLog.RowCount - 1
CursorLog.Position = i
Dim cmd As DBCommand
cmd.Initialize
cmd.Name =  "i" & i '"add_logs"

????
commands.Add(cmd)

Next
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should define an insert command in the config file.

Then do something like:
B4X:
Dim commands As List
commands.Initialize
For i = 0 To CursorLog.RowCount - 1
 CursorLog.Position = i
 Dim cmd As DBCommand
 cmd.Initialize
 cmd.Name = "InsertCommand"
 cmd.Parameters = Array(CursorLog.GetString("col1"), CursorLog.GetString("col2"))
 commands.Add(cmd)
Next
reqManager.ExecuteBatch(commands, null)
 
Upvote 0
Top