Possible Duplicate:
Oracle table change monitor
This is the question that is asked to me in one of the interviews:
I need to call some java method as soon as something gets updated in database. Can I call some java method through SQL trigger?
Possible Duplicate:
Oracle table change monitor
This is the question that is asked to me in one of the interviews:
I need to call some java method as soon as something gets updated in database. Can I call some java method through SQL trigger?
instead of polling main table, I would suggest to have one more table(with columns time stamp, reason) which contains summary of changes to main table. This improves the query performance.
Top 1 query on summary table gives the answer.
Generally, you should avoid filling the db ffom multiple apps. That's not always possible, so you need some ad-hoc mechanism. Polling is the best you can do, but you can simply poll the table you need, or another table populated by a trigger.
Invoking java from the database would violate your layer bounderies, and is a bad thing. Even if the DB somehow supports a magic callback mechaniam, I'd still be hesitant to use it.