This is how I understand the REPLACE COMMAND works:
First the REPLACE command starts replacing from the current position of the record pointer unless you use the ALL keyword. If this is done the REPLACE command starts at the top of the file and will replace the field with the specified vaule for all records.
Regardless where the record pointer is at, when you use the WHILE key word (with out ALL keyword) it will start replacing from the current record position until the criteria ISN'T met. This could be for next 1 record, 0 records or for several records. As soon as the criteria isn't met the replacing stops. Now, you could have several other records in a file that meet the criteria specified in the WHILE expression but the replace stopped because the expression wasn't met before these other records.
You'd have several options but I can think of 2 quick ones. One - order the table by the field being used in the criteria, Locate or Seek to the first record then use REPLACE WHILE. TWO - Use REPLACE FOR (w/o ALL keyword, it's unnecessary here) instead. This will start from the top of the file and replace all records that met the critera. I also think REPLACE FOR is optimizable so to me, this would be the way to do it.
Like I said this is the way I understand it to work. Hope this helps.
BW
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement