LOCATE VS REFRESH
LOCATE VS REFRESH
(OP)
I need to continuosly check a table record to find whether a column be modified from outside.
As far as I conceive I have two chanches
1) first locate and then loop refresh
PrMod.Locate('POSTAZIONE',isKeyPrmod,[]);
while (PrMod.FieldByName('COMANDO').AsString='X') do begin
PrMod.Refresh;
Application.ProcessMessages;
Sleep(20);
end;
2) Continuosly locate
repeat
PrMod.Locate('POSTAZIONE',isKeyPrmod,[]);
Application.ProcessMessages;
Sleep(20);
until (PrMod.FieldByName('COMANDO').AsString='X');
which of the two less charges my Server ?
As far as I conceive I have two chanches
1) first locate and then loop refresh
PrMod.Locate('POSTAZIONE',isKeyPrmod,[]);
while (PrMod.FieldByName('COMANDO').AsString='X') do begin
PrMod.Refresh;
Application.ProcessMessages;
Sleep(20);
end;
2) Continuosly locate
repeat
PrMod.Locate('POSTAZIONE',isKeyPrmod,[]);
Application.ProcessMessages;
Sleep(20);
until (PrMod.FieldByName('COMANDO').AsString='X');
which of the two less charges my Server ?
RE: LOCATE VS REFRESH
Not enough information to understand how point 2) is supposed to work.
- You not specified which Pascal implementation are using. I have a feeling it is not Pascal but Delphi, in which case your question is off-topic and should be asked in forum102: Embarcadero: Delphi . )
- You not specified the class of PrMod.
- You not specified how your query looks.
- You not specified what stores your data.
- You not specified your operating system.
Some alternatives to avoid repeating a query just to find out if something changed :- PostgreSQL has listen / notify, which helps to solve this elegantly.
- On Linux is easy to catch signal sent by another process on the same server.
- A TCP socket makes possible to get notification from local or remote process.
If still need to repeat a query, a trigger can keep a short log of a table's recent changes in a separate, considerably smaller table.Next time please post your code between [code] and [/code] TGML tags.
Feherke.
http://free.rootshell.be/~feherke/