Pages

Sunday, May 12, 2019

What Is Database Change Notification.

=======================
General
=======================
What Is 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.

For example:
Let us assume that the application is interested in being notified about result set changes to a query on the HR.EMPLOYEES table. 
The application can register the query on the hr.employees table with the database using the Change Notification Feature. 
If a user adds an employee, then the application can receive a database change notification when a new row is added to the table. 
A new query of hr.employees returns the changed result set.

When the database issues change notification, it can contain some or all of the following information:

Names of the modified objects. 
For example, the notification can specify that the hr.employees table was changed.

The type of change. 
For example, the message specifies whether the change was caused by an INSERT, UPDATE, DELETE, ALTER TABLE, or DROP TABLE.

The ROWIDs of the changed rows and the type of DML that changed them.

Global events such as STARTUP and SHUTDOWN (consistent only). 

In a Real Applications Cluster, the database delivers a notification when the first instance on the database starts or the last instance shuts down.

The notification contains only metadata about the changed rows or objects rather than the changed data itself. 
For example, the database does not notify the client that a monthly salary increased from 5000 to 6000. 
To obtain more recent values for the changed objects or rows, the client must query the database based on the information contained in the notification.

Database Change Notification is useful for an application that caches query result sets on mostly read-only objects in the mid-tier to avoid network round trips to the database. 

Such an application can create a registration on the queries it is interested in caching using the change notification service. 
On changes to objects referenced inside those queries, the database publishes a change notification when the underlying transaction commits. 
In response to the notification, the application can refresh its cache by re-executing the queries.


For example, the users of a Web forum application may not need to view new content as soon as it is inserted into the back-end database. 
Such an application is intrinsically tolerant of slightly out-of-date data, and hence can benefit from caching in the mid-tier. 

Database change notification is of help in this scenario in keeping the cache updated with the back-end database.

=======================
Error: 
=======================
ORA-29972: user does not have privilege to change/ create registration

=======================
Solution:
=======================
GRANT CHANGE NOTIFICATION to USER_A ;

=======================
Reference
=======================
Developing Applications with Database Change Notification

No comments:

Post a Comment