如何从Delphi应用程序监视SQL Server数据库表 [英] How to monitor SQL server database table from delphi application
问题描述
如何从Delphi应用程序中实时监视特定表
并获取新记录和更新记录数据?
通常,您可以使用数据库事件/通知/警报。确切的术语和实现取决于DBMS。有关详细信息,您可以在 AnyDAC文档中查看 DBMS警报机制。 / p>
在后端,您可能需要为所需表实现触发器。对于某些DBMS,不是必需的。例如,使用Firebird,触发器必须调用 POST_EVENT
语句。对于SQL Server,必须调用一组特殊的查询更新通知API运算符来准备表。
在客户端上,您应该使用任何一种特殊的API,或者是一种标准的SQL查询机制。例如,对于Firebird,必须使用特殊事件API。在Oracle中,后台线程+标准SQL API。
Delphi实现取决于DBMS和数据访问组件。一些示例:
- dbGo(ADO)使用特殊API实现时不支持通知;
- dbExpress-相同;
- IBX-将
TIBEvents
与Firebird一起使用; - AnyDAC-使用 TADEventAlerter 。它以统一的方式支持许多DBMS的许多不同机制。 披露:AnyDAC是我代表的公司的旗舰产品。
How can I monitor specific table from Delphi application (real time) and get new and updated records data ?
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:
- dbGo (ADO) does not support notifications, when they are implemented using special API;
- dbExpress - the same;
- IBX - use
TIBEvents
with Firebird; - AnyDAC - use TADEventAlerter. It supports many different mechanisms for many DBMS in a unified way. Disclosure: AnyDAC is the flagship product of the company I represent.
这篇关于如何从Delphi应用程序监视SQL Server数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!