Hi all
I have this logic in my app to locate for orphaned records and way to remove them. This code started to fail as it went into LAN. Could anyboby help me with a better logic, essentially in sigle user this works like a charm but LAN it fails to identify the truely orphaned records.
My logic is as follows in the startup of the Purcahse Bills screen:
Open Items Master (IDB) Database
Open Header Database (HDB) for Purchase Bills
Open Line Database (LDB) for Purchase Bills
Scan LDB for records having .F. in the registered field
locate and update corresponding master in IDB for this orphan record
delete orphan
endscan
When I save a HDB record I have the follwing logic in the save of Purhcase bills screen:
scan LDB for child of the current Purcahse Bill and having .F. in the registered field
replace registered field with .T.
endscan
In a single user this is all well, in a LAN now what happens is that a user is using the Purchase Bill and has already entered the items in the LDB (yet marked registered=.F.) but before he has the chance to save the HDB (where logic to mark registered=.T.) another user at a different place fires up the Purchase bill screen and the startup code is executed. This will delete the items of the first user.
The details of HDB is still in the memory so there is no way the second user knows that the records marked with registered=.F. are genuine orphans or not, so it deletes them.
Currently, I have stopped using the orphan records deletion logic. The reason for this logic is that the Items Master (IDB) is being updated by saving of the LDB and for modular purposes I have to update IDB from LDB save logic rather than from HDB save.
We have regular power-outages and not all of the machines have UPS and even if there are no power-outages users have a nack to Hang/Reset the machine.
Hope I have been able to explain my purpose and expectations of the above logic.
Please advise.