简体   繁体   English

当查询返回非空结果集时,我们如何观察 sql 查询

[英]How do we observe on a sql query when the query returns a non empty resultSet

If we have a Java process that fires a query as select name from Person where id = '123' , and another process which inserts the record with the id 123 , how can the first process be notified when the record has been inserted?如果我们有一个 Java 进程select name from Person where id = '123' ,另一个进程插入 id 为123的记录,当插入记录时如何通知第一个进程?

I think you might want to have a look into Database Change Notification:我想你可能想看看数据库更改通知:

Database Change Notification is a feature that enables client applications to register queries with the database and receive notifications in response to DML or DDL changes on the objects associated with the queries.数据库更改通知功能使客户端应用程序能够向数据库注册查询并接收通知以响应与查询关联的对象的 DML 或 DDL 更改。 The notifications are published by the database when the DML or DDL transaction commits.当 DML 或 DDL 事务提交时,通知由数据库发布。

During registration, the application specifies a notification handler and associates a set of interesting queries with the notification handler.在注册期间,应用程序指定一个通知处理程序并将一组有趣的查询与通知处理程序相关联。 A notification handler can be either a server side PL/SQL procedure or a client side C callback.通知处理程序可以是服务器端 PL/SQL 过程或客户端 C 回调。 Registrations are created on all objects referenced during the execution of the queries.注册是在查询执行期间引用的所有对象上创建的。 The notification handler is invoked when a transaction subsequently changes any of the registered objects and commits.当事务随后更改任何已注册对象并提交时,将调用通知处理程序。

https://docs.oracle.com/cd/B19306_01/B14251_01/adfns_dcn.htm#BGBBHGAH https://docs.oracle.com/cd/B19306_01/B14251_01/adfns_dcn.htm#BGBBHGAH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM