Android Sqlite SQLiteAbortException does not work -
My application uses some complex SQL statements, so I've often put in the bad habit of using execsql, Even when I should use something like / maybe insert for simple things (bottom) or update.
However, I'm wondering why this is not working
string queries = "update or abort" + MyTable + "SET" + .... Try the column name and value + ou ... {db.execSQL (query); } Hold (SQLiteAbortException e) {Log.i (tag, "error in updates");
I have tried to do it with data that should obviously fail (i.e., there is no matching record to update), but I'm not catching hold Initially I did update or failed and used a SQLiteConstraintException but when it was not caught I specifically tried
attempted an SQLattractException which indicates the exception that the SQLite program is terminated Ia was it could be a result of using or ABORT conflict section through call ABORT trigger either.
What am I missing here?
UPDATE: Just adding for reference on INSERT / UPDATE or ABORT / FAIL if the SQLiteAbortException is not the way, how to stop / fail the update? I tried to find an explanation for that behavior in the Java source code section of Android API Level 1, But the only place where SQLiteAbortException
is thrown (again) is in a static helper class called DatabaseUtils
. It is basically thrown by using a method from the original method This is thrown when SQLite returned error code 4, which is named SQLITE_ABORT
and:
/ * Callback routine has abort * /
I firmly believe that one callback function means it. You can register callbacks with SQLite and they think there are some levels of control. So it appears to me that the error code that is translated into SQLiteAbortException
does not have to do with the SQL ABORT
clause. In fact, I am very doubtful that The exception never throws, because I do not think the native part of the SQLite database driver of Android stops callback in SQLite which cancels the request.
This is also typical for the error code expected:
ABORT
When an applicable blockage violation occurs ,
ABORT
Resolve algorithm with current SQL statementSQLITE_CONSTRAINT
error (... snip)
So according to the documentation of SQLite and what the original Android is, the source code actually does, in that case SQLiteConstraintException
is expected and apparently the SQLiteAbortException
Documentation of Android is not entirely accurate.
Comments
Post a Comment