I have a form based on a set with a child and 4 grandchildren. The selected parent record and all child recs will be deleted when a user presses a button on the form. All works well except for the speed.
In some cases the first child will have 30-50,000 records and the delete takes 30+ minutes. If I run the same function, but not in context of the form, the delete takes 30 seconds. This is likely due to the way indexes are updated during the delete. It would be ideal if, from the button, I could close the form and launch the function that does the deletes. Code I have tried is below.
I was hopeful script_spawn() would work to allow the button script to keep running (and therefore finish and allow the form to close), but it also pauses the button script until the spawned script finishes.
script_schedule() is the only thing that allows the button script to finish and close the form. The obvious downsides are
1. the scheduled script may not fire for up to a minute.
2. I won't worry about the possibility of the minute changing at the precise time the schedule is set.
I really don't want to try to display all these child tables in an xdialog. Any other thoughts on a way to get the form to close while my delete_people_noform("Transfer",.t.) continues to run?
Bill.
In some cases the first child will have 30-50,000 records and the delete takes 30+ minutes. If I run the same function, but not in context of the form, the delete takes 30 seconds. This is likely due to the way indexes are updated during the delete. It would be ideal if, from the button, I could close the form and launch the function that does the deletes. Code I have tried is below.
Code:
parentform.Close() 'delete_people_noform("Transfer",.t.) 'script pauses till this finishes 'script_spawn("delete_people_noform") 'script pauses till this finishes vt = time("0h:0m", now()) vt = increment_value(vt) script_schedule("delete_people_noform",vt) 'works
script_schedule() is the only thing that allows the button script to finish and close the form. The obvious downsides are
1. the scheduled script may not fire for up to a minute.
2. I won't worry about the possibility of the minute changing at the precise time the schedule is set.
I really don't want to try to display all these child tables in an xdialog. Any other thoughts on a way to get the form to close while my delete_people_noform("Transfer",.t.) continues to run?
Bill.
Comment