dimanche 3 mai 2015

SQLITE UDPATe statement doesnt want to update

 SQLiteDatabase database = databaseHelper.getWritableDatabase();

    database.beginTransaction();
    long numRows = DatabaseUtils.queryNumEntries(database,
            TypeContract.CTablePhotoMatch.TABLE_NAME);// TOHLETO TO
    // ZPOMALUJE ASI
    // Fest!
    if (numRows < 1) {

        String sql = " INSERT INTO "
                + TypeContract.CTablePhotoMatch.TABLE_NAME + "("
                + TypeContract.CTablePhotoMatch.FK_OWNER + ","
                + TypeContract.CTablePhotoMatch.FK_ASSIGN + ","
                + TypeContract.CTablePhotoMatch.VALUE
                + ") VALUES (?, ?, ?);";

        SQLiteStatement stmt = database.compileStatement(sql);

        try {

            for (int i = 0; i < photoRecAssign.length; i++) {

                stmt.bindDouble(1, photoRecOwner);
                stmt.bindDouble(2, photoRecAssign[i]);
                stmt.bindDouble(3, value[i]);

                long entryID = stmt.executeInsert();
                stmt.clearBindings();

            }
            database.setTransactionSuccessful();
        } finally {
            stmt.close();
            database.endTransaction();
            // database.close();
        }

    } else {

        database.beginTransaction();
        String sql = " UPDATE " + TypeContract.CTablePhotoMatch.TABLE_NAME
                + " SET " + TypeContract.CTablePhotoMatch.VALUE + "=? "
                + " WHERE " + TypeContract.CTablePhotoMatch.FK_OWNER
                + "=? AND " + TypeContract.CTablePhotoMatch.FK_ASSIGN
                + "=? ";// is it
                        // oK?

        SQLiteStatement stmt = database.compileStatement(sql);

        try {

            for (int i = 0; i < photoRecAssign.length; i++) {

                stmt.bindDouble(2, photoRecOwner);
                stmt.bindDouble(3, photoRecAssign[i]);
                stmt.bindDouble(1, value[i]);

                long id = stmt.executeUpdateDelete();
                Log.v("--------TAG--------", "idid UPDATEU: " + id);

                stmt.clearBindings();

            }
            database.setTransactionSuccessful();
        } finally {
            stmt.close();
            database.endTransaction();
            // database.close();
        }

    }

Without error and compile-error,

the LONG id of update_execute() returns everytime 0....(affected rows) I dont know where canbe problem, the Insert works without the problem... Can I catch some more details?(Of sqlite statemenst) to find out the bug

Aucun commentaire:

Enregistrer un commentaire