robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

mass update #248

Closed hannesa2 closed 10 years ago

hannesa2 commented 10 years ago

On performance issue, I want to update all/some records with a complex statement at one step, eg

update table1 set colA = max(colB*1.4 , colC*1.331)

if I iterate it needs too much time. With this example I see only a static update value

 ContentValues values = Recipes.newBuilder()
  .setTitle("Scrambled Eggs")
  .getValues();

 SQuery.newQuery()
  .expr(Recipes.TITLE, Op.EQ, "Omelette")
 .update(Recipes.CONTENT_URI, values);

or is it possible to use ContentValues dynamically ? If yes, how ? Or how to solve my cardinal problem ? If a rawQuery or execSQL is the best solution, where is the entry point to access db variable ? Actually I try this:

public class XXXXOpenHelper extends AbstractXXXXOpenHelper {
    public static SQLiteDatabase database;

    @Override
    public void onOpen(SQLiteDatabase db) {
        database = db;
    }
hannesa2 commented 10 years ago

this works for me

public class XXXXOpenHelper extends AbstractXXXXOpenHelper {
   public static SQLiteDatabase database;

   @Override
   public void onOpen(SQLiteDatabase db) {
       database = db;
   }