【问题标题】:how to save the history of specific column in sqlite db如何在sqlite db中保存特定列的历史记录
【发布时间】:2020-08-28 03:52:19
【问题描述】:

我的应用程序包含 sqlite db,我的问题:如果特定列已更改或更新,是否有方法或方法可以保存和查看特定列的历史记录?我的应用程序基本上是用于项目的输入和输出。一切正常,但我想跟踪项目数量的历史,我无法弄清楚输出项目的代码:

boolean updateexistItemOutput(String itemname, String itemtype ,String itemsTypeOut, double outputQty, double total, double profit, double profitMultiple, double totalProfitSingle,
                          double totalProfitMultiple, String lastUpdated, String inOrOut, String notes) {
SQLiteDatabase sqLiteDatabase = getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(column_name, itemname);
contentValues.put(column_outputquantity, outputQty);
contentValues.put(column_itemsType,itemtype);
contentValues.put(column_total, total);
contentValues.put(column_profitSingle, profit);
contentValues.put(column_profitMultiple, profitMultiple);
contentValues.put(column_TotalprofitSingle, totalProfitSingle);
contentValues.put(column_TotalprofitMultiple, totalProfitMultiple);
contentValues.put(column_updateDate, lastUpdated);
contentValues.put(column_inOurOut, inOrOut);
contentValues.put(column_notes,notes);
contentValues.put(column_itemsTypeOut, itemsTypeOut);
return sqLiteDatabase.update(table_Name, contentValues, column_name + "=?", new String[]{itemname}) > 0;

}

【问题讨论】:

    标签: java android database sqlite


    【解决方案1】:

    我认为常见的方法是创建一个记录数据变化的新表History。

    每次更改数据时都应在 History 表中插入一条新记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-06
      • 1970-01-01
      • 1970-01-01
      • 2021-02-10
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多