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)

 

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