Applies to: reported in 2012; no Clarion or server version is named. One answer is written for MySQL.
Problem as reported
A table has a description column and a sort-order column (1, 2, 3) that sets the order of a drop-down list. The poster wanted a SQL statement that spaces the numbers out (1, 5, 10, 15) so a new description can be slotted in between. He could do it in Clarion code but wanted a SQL solution.
What the thread found
- Multiplying the column,
update mytable set mysortorder = mysortorder * 5, was suggested for a one-time job. The poster feared duplicates when the numbers are not in order (his example 1, 5, 3, 2: the 1 times 5 would meet the existing 5). Another poster did not think a duplicate would appear, because the database sees only the end result of the transaction. - Another poster explained that the statement works even with a unique constraint on the column: SQL does not change the rows one at a time as a Clarion SET/NEXT/PUT loop does, so a changed row cannot collide with a row not yet changed. In Clarion terms, all values are computed first and written back together.
- A MySQL form with a descending order was posted:
UPDATE MyTable SET MySortOrder = MySortOrder * 5 WHERE MySortOrder > 1 ORDER BY MySortOrder DESC. The poster said it should be similar on other servers, and the original poster thought the DESC was the key. - A further suggestion was to drop the primary key, run the update and recreate the key.
- The original poster called the single-statement answer "pretty cool". He did not report a test of it.
Caveats
- ORDER BY inside UPDATE is MySQL syntax; the thread did not check other servers.
- Dropping the key was the least favoured idea and was not tried.
Today (2026)
Not reproduced. The set-based explanation is general SQL and likely still holds, but this entry has not been re-tested. A reader who ran it on a current server is asked to confirm or close it.
Sources: Don S. (Jan 2012, the question), Arnor B., Sean H., Jon W., Markus S., Djordje R. (Jan 2012) in softvelocity.clarion.databasedrivers.