Skip to content Skip to sidebar Skip to footer

"in Place" Update In Android Sqlite Database Not Working With Rawquery

I need to execute an 'in place' update SQL Query on an SQLite database in my android application. The query is of the form: update table T set column = column + 1 where someOtherC

Solution 1:

Is there some way I can update "in place" by using the first query?

That's not a query. It's an UPDATE statement. It does not return a result set. Use it with execSQL(), not rawQuery().

but this requires me to fetch the old column value, update it outside and then execute update() which is probably less efficient since it requires a select and then an update

This is the way all SQL databases work. Now, those that offer stored procedures may be able to let you do an UPDATE and a SELECT in one request, but it is still an UPDATE and a SELECT. Furthermore, SQLite does not support stored procedures, at least when I last looked.

Post a Comment for ""in Place" Update In Android Sqlite Database Not Working With Rawquery"