B4J Question AddNonQueryToBatch

johnB

Active Member
Licensed User
Longtime User
I would be grateful if somebody can tell me what is wrong with my code. I get Success = True but not records in the DB. The AddNonQueryToBatch seems to be correct

Code:
    Main.SQL1.ExecNonQuery("DROP TABLE Test_Load")
    Main.SQL1.ExecNonQuery("CREATE TABLE IF NOT EXISTS Test_Load(Close INTEGER)")

    For i = 1 To 1000
        Main.SQL1.AddNonQueryToBatch("INSERT INTO Test_Load VALUES (?)", Array(i))
    Next
    Dim SenderFilter As Object = Main.SQl1.ExecQueryAsync("SQL", "SELECT * FROM Test_Load", Null)
    Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet)
    If Success Then
        Do While rs.NextRow
            Log(rs.GetInt2(0))
        Loop
        rs.Close
    Else
        Log(LastException)
    End If

I also tried

Code:
Main.SQL1.ExecNonQuery("PRAGMA journal_mode = wal")

But I got an error message. I put it immediately after the Create statement

Thanks
 
Compare your code with Erels.... Xou are adding the queries to the Batch but you did not Execute the Batch.

For i = 1 To 1000
Main.SQL1.AddNonQueryToBatch("INSERT INTO Test_Load VALUES (?)", Array(i))
Next
Dim SenderFilter As Object = Main.SQl1.ExecQueryAsync("SQL", "SELECT * FROM Test_Load", Null)


Code:
For i = 1 To 1000
   sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")
 
Upvote 0
Compare your code with Erels.... Xou are adding the queries to the Batch but you did not Execute the Batch.




Code:
For i = 1 To 1000
   sql.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = sql.ExecNonQueryBatch("SQL")


Thanks Don

Don't know where I got that code from, thought that I copied it from somewhere
 
Upvote 0
Back
Top