iOS Question Sqlite Error?

ilan

Expert
Licensed User
Longtime User
hi

i encounter an error lately when using sqlite (sql) library on b4i.
i have a b4x (b4xpages) app that runs on b4a and b4i. i had no issues until now and if i run the same code with the same database on both platforms on android it works fine but on b4i i got an error. something that i did not had before.


"Unknown error calling sqlite3_step (11: database disk image is malformed) rs"

if i google it i got that the database is corrupted but it is not because i open it on b4j, b4a and other sql reader apps like sqlite db browser. on all it works fine but on b4i i got an error.
it happens on this line:

B4X:
If Main.sql1.ExecQuerySingleResult($"SELECT count(*) FROM shiurim WHERE audioid = '${id}'"$) > 0 Then

so a really simple query command.
any ideas? (i am using the hosted builder)

Application_Start
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
Application_Active
Unknown error calling sqlite3_step (11: database disk image is malformed) rs
g91MLDeb
Unknown error calling sqlite3_step (11: database disk image is malformed) rs
Error occurred on line: 1205 (B4XMainPage)
Cannot parse:
Stack Trace: (
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 185864
libobjc.A.dylib objc_exception_throw + 88
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 1550048
result -[B4I ObjectToNumber:] + 392
result -[ResumableSub_b4xmainpage_loadaudiolessons resume::] + 3048
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 196148
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 192124
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1352
result -[B4IShell runMethod:] + 320
result -[B4IShell raiseEventImpl:method:args::] + 928
result -[B4IShellBI raiseEvent:event:params:] + 1008
result -[B4IDelegatableResumableSub resume::] + 336
result -[B4I checkAndRunWaitForEvent:event:params:] + 468
result -[B4IShellBI raiseEvent:event:params:] + 904
result __37-[B4ICommon ReturnFromResumableSub::]_block_invoke + 256
libdispatch.dylib C05E486D-81F2-367E-9CE1-E14573C4C268 + 8776
libdispatch.dylib C05E486D-81F2-367E-9CE1-E14573C4C268 + 16296
libdispatch.dylib C05E486D-81F2-367E-9CE1-E14573C4C268 + 76340
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 498636
CoreFoundation 0013A8B1-2524-3534-B5BA-681AAF18C798 + 483776
CoreFoundation CFRunLoopRunSpecific + 588
GraphicsServices GSEventRunModal + 164
UIKitCore 8CC54497-F7EC-3903-AE5A-A274047C0CF1 + 4122228
UIKitCore UIApplicationMain + 340
result main + 96
dyld A770FF8C-8FB9-3E03-85FE-7F26DB36812B + 196072
)
Class (b4i_httpjob) instance released.
 

ilan

Expert
Licensed User
Longtime User
so what i found out is that the SELECT count(*) always returns an empty string in B4i but not in b4a with the same database

B4X:
Log( Main.sql1.ExecQuerySingleResult("SELECT count(*) FROM shiurim"))

logs:

(empty string)

the database is definitely not empty!!

why does it return an empty string?
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Ok so after deleting the app and reinstall it works. Don't know why :(

I do not know why but I have faced also several strange things with sqlite. For example in multi joins of tables you have to put the table joins in series the way they are connected because if you do not do it in series instead of the field values it returns the field names (if I recall correctly)...

(not f.e. FROM ((tbl1 INNER JOIN tbl2 ON tbl1.fld1 = tbl2.fld2) INNER JOIN tbl3 ON tbl1.fld1 = tbl3.fld3) INNER JOIN tbl4 ON tbl4.fld4 = tbl2.fld2
but f.e. FROM tbl3 INNER JOIN tbl1 ON tbl3.fld3=tbl1.fld1 INNER JOIN tbl2 ON tbl1.fld1 = tbl2.fld2 INNER JOIN tbl4 ON tbl4.fld4 = tbl2.fld2)

The twilight zone database...
 
Upvote 0
Top