How to rearrange table after deleting first row in sqlite?
I have 1 table in sqlite, I am inserting values to that table. when the insertion row id greater than 100 I want to delete first inserted record and insert new record at 100th location, I开发者_StackOverflow中文版 am deleted 1st record but 2nd record in 2nd place but i want rearrange the record after deleting first row. How can I do it?
My table name is: Products
My table contains productName,productId,...
My DatabaseName is: HalalGauge.sqlite
Add your new row as productId 101. DELETE FROM PRODUCTS WHERE productId = 1 UPDATE PRODUCTS set productId = (productId-1)
I wouldn't call this a nice solution as it updates every row but if you only have 100 rows it will be ok.
you need to use this methods for rearranging
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
toIndexPath:(NSIndexPath *)toIndexPath;
精彩评论