index field update

vickey

New Member
Hi Everybody,

I am facing problems when trying to update an indexed field within a for each statment. The same records is begins re-read in the for each loop multiple times.

What is even more bothering is the install script for the same field works fine while the problem stated is happening only with the rollback script for the same field.

Thanks in Advance
GV
 

doreynie

Member
You're probably updating your keyfields. Use a preselect each to get a result list for your query in memory, before you begin updating your keyfields.
 

vickey

New Member
Thanks for the prompt reply. That did work. But any idea why the same problem dint occur for the install script which used the same logic to update the same field.

Also do i have to modify all the scripts which updates the key field to preselect instead of the for each although i dint face any problem while testing with sample data.

code snippet(install):

for each <table name> where <condition>:
assign <key field> = "0" + <key field>.
end.

code snippet(Rollback):

for each <table name> where <condition>:
assign <key field> = substring(key field,2).
end.

Thanks
GV
 

doreynie

Member
If the keyfields that you're updating aren't in the where-condition, then you don't have to use the preselect option. Progress doesn't build a result list that matches your query (for each....) first. So it starts the for each... and does continue until there are no more records to find that meet the condition. If you change you're keyfields during the for each iteration, and those key-fields are in the where-condition, than it's possible that you are in and enless loop. If you don't have the keyfields that you are updating in your where-condition, then at some point, the for each ... condition will not find records any more that meet the condition and will end.
 
Top