中国开发网: 论坛: 超级垃圾站: 贴子 577789
leejd
Asynchronous database event notifications[supported PostgreSQL and Firebird]
Asynchronous database event notifications
Posted by Anders Larsen
in Qt
on Friday, November 02, 2007 @ 10:32
zt[http://labs.trolltech.com/blogs/2007/11/02/asynchronous-database-event-notifications/]

Wouldn’t it be nice if your database could tell you that something it thinks you should know about just happened? For example that a record was inserted, modified or deleted from your favorite table. Well, some databases actually can and as of Qt 4.4 you may be able to take advantage of this in your Qt applications.

Imagine an asynchronous event notification as a signal emitted from the database to announce the occurrence of a specified condition or action. The message can be posted automatically from a trigger or a stored procedure, or even manually from a shell. The message is very lightweight: nothing more than a string containing the name of the event that occurred.

To subscribe to an event just use QSqlDriver::subscribeToNotification(). When an event that you’re subscribing to is posted by the database the driver will emit the notification() signal and your application can take appropriate action.

Currently this feature is only supported by the PostgreSQL and Interbase/Firebird drivers, but support may be added to other drivers in the future. Use QSqlDriver::hasFeature() to check whether the feature is available or not in the driver you’re using.

If you can’t wait until Qt 4.4 to start hacking with asynchronous database events they are already available in the snapshots.

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录