469,282 Members | 2,123 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

How can I update a set of records in one single query PLEASE HELP


My records contain a position, from 1 to n.
This position is not the primary key.
In normal conditions, the position of this records should be as
1, 2, 3, 4, 5, 6, 7, 8, 9 .etc...
One of my utitities is meant to check the consistency of the table -
one of the things it has to do is scan the table as follows:

SELECT position FROM employe_records WHERE employe_id = ? ORDER BY

From the result of this query I verify each entry (JDBC) one by one,
looking for inconsistancies. In a for() loop I look at the value of
position and check that they start from 1 and are incremented by one
for each record.
At the first inconsistency I come accross I want to run a query to
update the records so it is consistant again - it is something like

UPDATE employe_records SET position = updatedValue FROM
employe_records WHERE employe_id = ? ORDER BY position

This is not valid query of course - my question is what should my
query look like?! How can I make 'updatedValue' incremented by one
automatically so each of the records are updated from 1 to n

Many thanks!
Jul 19 '05 #1
0 1102

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Philip Boonzaaier | last post: by
10 posts views Thread by Randy Harris | last post: by
3 posts views Thread by Slower Than You | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.