Reputation: 355
How can I monitor specific table from Delphi application (real time) and get new and updated records data ?
Upvotes: 6
Views: 3883
Reputation: 7750
In general, you can use database events / notifications / alerts. The exact term and implementation depends on a DBMS. For details you can check "DBMS alert mechanisms" at AnyDAC documentation.
On a backend you may need to implement triggers for required tables. For some DBMS it is not required. For example, with Firebird a trigger has to call POST_EVENT
statement. With SQL Server the special set of Query Update Notification API operators must be called to prepare a table.
On a client you should use either special API, either standard SQL query mechanism. For example, with Firebird the special event API must be used. With Oracle a background thread + standard SQL API.
The Delphi implementation depends on a DBMS and data access components. Some examples:
TIBEvents
with Firebird;Upvotes: 8
Reputation: 70369
SQL Server 2005 and up has a notification mechanism... but I don't know of any free component supporting this mechanism...
IF a commercial component is an option Devart SDAC supports this.
The only other option I see would be to poll (perhaps from a background thread) - but polling is usually something you want to avoid IMO.
Upvotes: 1