当查询返回一个非空的结果集时,我们如何观察 SQL 查询的情况。

huangapple go评论76阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年7月29日 00:11:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63138422.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定