Am having two Table Table1 and Table 2 Table 2. Am trying to copy Column rawQty from table 1 to table 2. But it copying only first row of the table duplicating the same item in the row.Am tried with two Query.Both are giving the same result. Here is my code
public void copyItemToReset(){
SQLiteDatabase db = MmpDBHelper.this.getWritableDatabase();
String sql1 = "UPDATE " + ITEM_DETAIL_TABLE + " SET " +ITEMDETAIL_RAWQTY + "= ( " +" SELECT " + ITEM_REFRESH_RAWQTY + " FROM " + ITEM_REFRESH_TABLE+") WHERE EXISTS " +
"( SELECT * FROM " + ITEM_REFRESH_TABLE + " WHERE " +ITEM_DETAIL_TABLE+"."+ITEMDETAIL_BOMNO + "="+ITEM_REFRESH_TABLE+ "." +ITEM_REFRESH_BOMNO+")";
String sql2 = "UPDATE " + ITEM_DETAIL_TABLE + " SET " +ITEMDETAIL_FINIQTY + "= ( " +" SELECT " + ITEM_REFRESH_FINIQTY + " FROM " + ITEM_REFRESH_TABLE+")";
String sql3 = "UPDATE " + ITEM_DETAIL_TABLE + " SET " +ITEMDETAIL_QTYUMUSED + "= ( " +" SELECT " + ITEM_REFRESH_QTYUMUSED + " FROM " + ITEM_REFRESH_TABLE+")";
try {
Log.i("sql1=", sql1);
Log.i("sql2=", sql2);
Log.i("sql3=", sql3);
db.execSQL(sql1);
db.execSQL(sql2);
db.execSQL(sql3);
} catch (Exception exe) {
exe.printStackTrace();
db.endTransaction();
Log.e("Insertion failed",
"Transaction failure when inserting itemdet data.");
this.closeDatabase();
Log.i("DB closed", "Database closed successfully and Copied Successfully");
errCode = "Err-DB-06";
LogFileCreator.appendLog(errCode + " : " + exe.getMessage());
}
}
Aucun commentaire:
Enregistrer un commentaire