How to update the values of one column based on user input.Suppose i have 10 values in one column as 1,2,3....9,10.If I change any value lets say 5 to 1 and 10 to 2.Then the Sequence of 1,2,3,4,5,6,7,8,9,10 should change to 3,4,5,6,1,7,8,9,10,2 and the values should update in DB after the changes was made.
***Updated by Moderator: Marissa to update categories***
Exactly,not only for 10 numbers should applicable for N no.of numbers.If i change any number in the sequence lets say from 1 to 100,you change 9 to 3 and 88 to 2 ,then it should be 1,4,5,6,7,8,9,10,3,11,12,.....84,85,86,87,88,2,89,90 .......99,100.
Make a count of no of values you changed and their indexes.
Ex: sequence lets say from 1 to 100,you change 9 to 3 and 88 to 2 ,then it should be 1,4,5,6,7,8,9,10,3,11,12,.....84,85,86,87,88,2,89,90 .......99,100.
So, count = 2 and need to change indexes are 9,88. Values which has to replaced are 3,2.
Starting index value which got removed is least value among (3,2) so it is 2.
So, we will start the sequence until its value (2). Ex: 1, ........
From the index value of 2, increment the value with the count. So, sequence will be 1,2+2,3+2,..... which will be 1,4,5,6,...
Then need to change indexes are 9,88. So, when pyForEachcount reaches value of 9 then, get the first value from value which has to get replaced. i.e. 3 and append the value in the sequence. Then count(value needs to be changed) will be reduced to 1 and the next values in the sequence will be incremented by 1 after insertion.
Sequence will be 1,4,5,6,7,8,9,10,3,10+1=11,11+1=12,12+1=13,13+1=14.....
When it reaches index 88, then 2 has to append in the sequence and count will be reduced to 0.
Finally, sequence will be 1,4,5,6,7,8,9,10,3,11,12,.....84,85,86,87,88,2,89,90 .......99,100. This is the logic.