MTilsted MTilsted - 2 months ago 5
Android Question

In which case will sqlite executeInsert return -1?

The documentation for executeInsert in the SQLiteStatement class say that:

@return the row ID of the last row inserted, if this insert is successful. -1 otherwise.

But it can also cast an exception if the query fails, so in what cases will it choose to return -1 instead of throwing an exception?

CL. CL.
Answer

It is possible to have an INSERT statement that is valid SQL but that does not actually insert any record. When using the INSERT ... SELECT form, the SELECT query might not actually return any records.

Comments