I could not find any reference in the docs to the PRAGMA command where you referenced it. Am I missing something?
Anyway the command
B4X:
SQL.ExecNonQuery("PRAGMA integrity_check(100)")
as does
SQL.ExecNonQuery("PRAGMA integrity_check(1)")
as does
SQL.ExecNonQuery("PRAGMA integrity_check")
throws an error
android.database.sqlite.SQLiteException: unknown error: Queries can be performed using SQLiteDatabase query or rawQuery methods only.
Dim SQLReader As Cursor
Dim i As Int
SQLReader = SQL1.ExecQuery("PRAGMA integrity_check(100)")
If SQLReader <> Null Then
lstvCAT.Clear
For i = 0 To SQLReader.RowCount - 1
SQLReader.Position = i
lstv.AddTwoLines2(SQLReader.GetString("Code"),SQLReader.GetString("Name"),SQLReader.GetString("id"))
Next
SQLReader.Close
End If
ExecQuerySingleResult does not work nor is the field called integrity_check. Appreciate the help but have you checked the code you are posting? If you are then I must be missing something else.
This executes without an error
B4X:
Cursor1=SQL.ExecQuery("integrity_check")
Cursor1.Position = 0
If Cursor1.RowCount > 0 Then
.... errors
But i cannot test it on a bad database as yet
UPDATE:
Ok I have my corrupt database installed; run the command above and it just flows through without signalling a problem
the above code ^posted as example on how I use cursor ofc the fieldnames not exist...
B4X:
Dim kk As Cursor
kk= General.ExecQuery("PRAGMA integrity_check(100)")
kk.Position=0
Msgbox(kk.GetString2(0),"test") //returns ok
Msgbox(kk.GetColumnName(0),"test") //returns integrity_check
Msgbox(kk.ColumnCount,"test") //returns 1
Msgbox(kk.RowCount,"test") //returns 1 , if returns > 1 there are errors
so the final code will be :
B4X:
Dim kk As Cursor
kk= General.GetCursor("PRAGMA integrity_check(100)")
If kk.RowCount > 1 Then
For i = 0 To kk.RowCount -1
kk.Position=i
Msgbox(kk.GetString2(0),"error")
Next
End If
It works with the word PRAGMA. However without that word there are no errors and the code seems to execute.
Now a strange problem. I have tested on a database that appears corrupt. I get the message ok but i am unable to access ANY tables in the database. However if i open the db on the computer with Sqllite Administrator it opens ok and the tables are there
I have the database there on many copies of the program without ill effect. I sent this particular copy to Erel when it became 'damaged'. he was unable to open it either. It is not the location, if i overwrite the db with another copy the program works fine. Besides I use the other location for backup copies
UPDATE:
Using that sqlite manager you pointed to gives me an error when i open the db "database disk image is malfrmed"
Yet it WILL open with Sqllite Administrator
So to Recap...
I HAVE A MALFORMED DATABASE which cannot be accessed on the tablet and not a single table exists when i try to open them on the tablet but the PRAGMA Integrity Check says it is ok
Dont think so. It was ok until a user reported the program could no longer access the db. when i transfered it to another tablet I found that it was Malformed according to the android error message but could open it with SOME sqlite managers but not all