Hello!
I have just tested the sync-functionality of my app under ios. Unfortunately it failed... Under android the same code works fine.
The situation: I call a sub to insert / update a unique row in the database based on a group which is also stored in the database. The source is json and comes from a webserver. I query the groups one after each other, what means the outer resultset is open the whole time to get the next group-id.
First i check if the id is already inserted. Because of the missing rowCount under ios i use this construct
It failed direct at the first entry, so exist=false. In this case i create a insert-query and send it as ExecNonQuery. The following error is exact in this line:
I think the problem is because i have one open recordset - a recordset that query the local group of entrys i want to get from the server. It is possible to use lists instead of resultsets, but there are many in the project and maybe there is a easier solution. Mabye i can configure the transaction that it works like under android... Has anybody a idea?
Regards
Matthias
I have just tested the sync-functionality of my app under ios. Unfortunately it failed... Under android the same code works fine.
The situation: I call a sub to insert / update a unique row in the database based on a group which is also stored in the database. The source is json and comes from a webserver. I query the groups one after each other, what means the outer resultset is open the whole time to get the next group-id.
First i check if the id is already inserted. Because of the missing rowCount under ios i use this construct
B4X:
Dim result As ResultSet
Dim exist As Boolean = False
Dim stlu As Int=0
result=sql1.ExecQuery("Select lu from farms where id='" & id.Replace("'","''") & "'")
If result.NextRow Then
exist=True
stlu=result.GetInt("lu")
Else
exist=False
End If
result.close
If exist=False Then
SQLE("Insert into ...") '< This function is called
Else
...
end if
B4X:
Sub SQLE(sqlQuery As String)
sql1.ExecNonQuery(sqlQuery) '< Error when inserting under ios when a resultset is already open
End Sub
B4X:
Unknown error calling sqlite3_step (5: database is locked) eu
DB Query: begin exclusive transaction
Unknown error finalizing or resetting statement (5: database is locked)
DB Query: begin exclusive transaction
Error occurred on line: 85 (database)
BeginTransaction error: database is locked
Stack Trace: (
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 1220052
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 126580
B4i Example -[B4ISQL BeginTransaction] + 156
B4i Example -[B4ISQL ExecNonQuery2::] + 116
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 1240532
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 9172
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1300
B4i Example -[B4IShell runVoidMethod] + 232
B4i Example -[B4IShell raiseEventImpl:method:args::] + 1800
B4i Example -[B4IShellBI raiseEvent:event:params:] + 1580
B4i Example +[B4IDebug delegate:::] + 80
B4i Example -[b4i_database _updateanimal:::::::::::::::::::::] + 1724
B4i Example -[ResumableSub_sync_syncNow resume::] + 12232
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 1240532
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 9172
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1300
B4i Example -[B4IShell runMethod:] + 448
B4i Example -[B4IShell raiseEventImpl:method:args::] + 2172
B4i Example -[B4IShellBI raiseEvent:event:params:] + 1580
B4i Example -[B4IDelegatableResumableSub resume::] + 380
B4i Example __21-[B4ICommon Sleep:::]_block_invoke + 48
libdispatch.dylib FF408738-D75B-3061-AD99-4A929C0162D2 + 10884
libdispatch.dylib FF408738-D75B-3061-AD99-4A929C0162D2 + 18460
libdispatch.dylib _dispatch_main_queue_callback_4CF + 884
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 670252
CoreFoundation A408A063-A023-3AAA-A674-0FF01607F818 + 645380
CoreFoundation CFRunLoopRunSpecific + 600
GraphicsServices GSEventRunModal + 164
UIKitCore F9E6CF6F-3B15-3C66-8C35-951AFD4D0CC4 + 12363612
UIKitCore UIApplicationMain + 168
B4i Example main + 120
libdyld.dylib 1A4BE407-C230-309B-AEAB-8E9C62BD377A + 7416
)
I think the problem is because i have one open recordset - a recordset that query the local group of entrys i want to get from the server. It is possible to use lists instead of resultsets, but there are many in the project and maybe there is a easier solution. Mabye i can configure the transaction that it works like under android... Has anybody a idea?
Regards
Matthias