Subject Re: FireBird Events
Author Adam
--- In firebird-support@yahoogroups.com, "sasidhardoc"
<madhusasidhar@n...> wrote:
> I want to use POST_EVENT in my database to monitor changes in a table.
> Suppose I have a Table with fields STOCK_ID (generator value) and
> STOCK_PRICE. I want my application to respond when the stock price is
> changed. I intend to do this with a POST_EVENT inside an UPDATE Trigger.
> But, if my application is only viewing a few stocks, then, the
> application should be able to discern if the POST_EVENT was raised by
> a change in STOCK_PRICE of the stocks it is viewing. My question is,
> how do I inform the application as to which record was modified? I
> suspect I could do this using
> POST_EVENT event;
> where event variable = STOCK_ID
> However, my database has several tables with _ID fields that I want to
> monitor and the generator values may be identical.

Add a timestamp field to the table and fill it using 'NOW' either
triggers or the default value (if you can).

When the stock price changes, fire the stock price event. When you
initially query the stock prices, take note of the maximum timestamp,
and when you reissue the query, add a timeofinterest > :thattime to
the where clause.

If performance isn't already acceptable, you can always index the field.

Adam