Updating tables based on Oracle JDBC Database Chan

2019-08-31 11:52发布

问题:

How to get change notifications for rows updated such as row data/row description. I am able to get rows Id's which are updated.

I need to sync Table1 with Table2 based on the row Id's that I get as notification after updating Table1. I have read on few sites about notifications, but couldn't find any information on how to update a table based on notification. Please help!!

Below is some help information I found on Oracle website:

Applications in the middle tier require rapid access to cached copies of database objects while keeping the cache as current as possible in relation to the database. Cached data becomes out of date or "stale" when a transaction modifies the data and commits, thereby putting the application at risk of accessing incorrect results. If the application uses Database Change Notification, then Oracle Database can publish a notification when a change occurs to registered objects with details on what changed.

In response to the notification, the application can refresh cached data by fetching it from the back-end database.

回答1:

Looking at the Application Developer's Guide you cited I note that about the sixth paragraph under the "Developing Applications with Database Change Notification" states:

The notification contains only metadata about the changed rows or objects rather than the changed data itself.

So there doesn't appear to be a way to get Oracle to tell you that FIELD_X or DESCRIPTION or whatever changed. Once the change notification is received which tells you the table and the ROWID you need to go out and fetch the data which was altered (if that's appropriate), and update the cached copy.

Your mileage may vary.

Share and enjoy.