Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LOCATE VS REFRESH 1

Status
Not open for further replies.

PERMAL

Programmer
Jul 8, 2011
2
IT
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 ?
 
Hi

Not enough information to understand how point 2) is supposed to work.
[ul]
[li]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 . )[/li]
[li]You not specified the class of PrMod.[/li]
[li]You not specified how your query looks.[/li]
[li]You not specified what stores your data.[/li]
[li]You not specified your operating system.[/li]
[/ul]
Some alternatives to avoid repeating a query just to find out if something changed :
[ul]
[li]PostgreSQL has [tt]listen[/tt] / [tt]notify[/tt], which helps to solve this elegantly.[/li]
[li]On Linux is easy to catch signal sent by another process on the same server.[/li]
[li]A TCP socket makes possible to get notification from local or remote process.[/li]
[/ul]
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 [tt][ignore]
Code:
[/ignore][/tt] and [tt][ignore]
[/ignore][/tt] TGML tags.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top