【发布时间】:2011-08-29 09:13:39
【问题描述】:
我在 sqlite 中有 1 个表,我正在向该表插入值。当插入行 id 大于 100 时,我想删除第一个插入的记录并在第 100 个位置插入新记录,我删除了第 1 条记录,但第 2 条记录在第 2 位,但我想在删除第一行后重新排列记录。我该怎么做?
我的表名是:Products
我的表包含 productName,productId,...
我的数据库名称是:HalalGauge.sqlite
【问题讨论】:
我在 sqlite 中有 1 个表,我正在向该表插入值。当插入行 id 大于 100 时,我想删除第一个插入的记录并在第 100 个位置插入新记录,我删除了第 1 条记录,但第 2 条记录在第 2 位,但我想在删除第一行后重新排列记录。我该怎么做?
我的表名是:Products
我的表包含 productName,productId,...
我的数据库名称是:HalalGauge.sqlite
【问题讨论】:
将您的新行添加为 productId 101。 从 productId = 1 的产品中删除 更新产品集 productId = (productId-1)
我不会称这是一个很好的解决方案,因为它会更新每一行,但如果你只有 100 行就可以了。
【讨论】:
你需要使用这个方法来重新排列
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
toIndexPath:(NSIndexPath *)toIndexPath;
【讨论】: