I have a table with OrderSequence, thean OrderSequence
column. The schema looks roughly like this:
- id
- Name
- OrderSequence
id
Name
OrderSequence
I have an arraysarray of ids ["1", "2", "3", "4"] from an application, iand I want to set the SequenceOrderOrderSequence
for sorting purposepurposes. I don't want to loop it viathrough the rows from the application and execute N number of sql, executing 'n' SQL queries one at a time. How should ican I do itthis using a stored proceduresprocedure?
Now the looks like
Sample data
id Name OrderSequence
1 A 0
2 B 0
3 C 0
What i want to achieve
Desired result
id Name OrderSequence
1 A 1
2 B 2
3 C 3
Using a stored procedure is ideal or if there's a way to update this in one sql command?