英文:
How do we observe on a sql query when the query returns a non empty resultSet
问题
如果我们有一个Java进程,执行查询如select name from Person where id = '123'
,还有另一个进程插入了带有id 123
的记录,那么当记录被插入后,如何通知第一个进程呢?
英文:
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?
答案1
得分: 1
我认为您可能想要了解一下数据库更改通知:
> 数据库更改通知是一项功能,它使客户端应用能够向数据库注册查询,并在与这些查询相关的对象发生DML或DDL更改时接收通知。这些通知是在DML或DDL事务提交时由数据库发布的。
>
> 在注册过程中,应用程序会指定一个通知处理程序,并将一组有趣的查询与通知处理程序关联起来。通知处理程序可以是服务器端的PL/SQL过程,也可以是客户端的C回调。在执行查询过程中,会在所有涉及的对象上创建注册。当事务随后更改所注册的任何对象并提交时,将调用通知处理程序。
https://docs.oracle.com/cd/B19306_01/B14251_01/adfns_dcn.htm#BGBBHGAH
英文:
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. The notifications are published by the
> database when the DML or DDL transaction commits.
>
> 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. 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论