0

How to write the following command into sqlitedatabase update() function ?

String query="update " + TABLE_TASKS + " SET " + TASK_LEFT + "=CASE WHEN " + TASK_LEFT + ">= " + left +" THEN " + TASK_LEFT + "+2 ELSE " + TASK_LEFT + " END, " + TASK_RIGHT + "=" + TASK_RIGHT + " +2 WHERE " +TASK_RIGHT +" >= " + right;

Basically I want to know how to insert multiple clauses and WHEN THEN clauses into update() function?

mango
  • 5,577
  • 4
  • 29
  • 41
vikas
  • 1,318
  • 4
  • 16
  • 33

1 Answers1

0

The update method takes the new values as a ContentValues object, which contains only fixed values. It does not allow reading old values from the database in the same step.

If you want to write SQL that is more complex than update allows, you have to use execSQL instead.

CL.
  • 173,858
  • 17
  • 217
  • 259