In this case, u need not to use while select statement. Better use two separate select statements for update.
select forupdate tablename where tablename.status == enum::active;
tablename.status = close;
tablename.clear();
select firstonly forupdate tablename order by recId where table.status == open;
tablename.status = active;
(You can use the second update in the above code if you want the first record with open status or else use your own logic for fetching the proper record)
In this case, u need not to use while select statement. Better use two separate select statements for update.
select forupdate tablename where tablename.status == enum::active;
tablename.status = close;
tablename.clear();
select firstonly forupdate tablename order by recId where table.status == open;
tablename.status = active;
(You can use the second update in the above code if you want the first record with open status or else use your own logic for fetching the proper record)