有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在sqlite数据库中保存特定列的历史记录

我的应用程序包含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;

}


共 (1) 个答案

  1. # 1 楼答案

    我认为常用的方法是创建一个记录数据更改的新表历史记录

    每次更改数据时,都应在历史记录表中插入一条新记录