Subject Re: FireBird Events
Author colinriley666
My application has an identical requirement (for quantity in stock). I
achieve it as follows:
The after_update trigger posts event "STOCK" || stock_id.

Each client registers interest in its products. There is one instance
of class TFFDStock for each product I'm intersted in:

constructor TFFDStock.Create(...);
begin
inherited;
fIBEvent := TSIBfibEventAlerter.Create(nil);
with fIBEvent do begin
Database := dmMain.dbEvents;
OnEventAlert := EventAlert;
Name := 'STOCK' + Id;
Events.Add(name);
Registered := True;
end;
end;

When stock changes, this method is invoked:

procedure TFFDStock.EventAlert(Sender: TObject; EventName: String;
EventCount: Integer);
begin
dataset.Refresh;
end;


regards, Colin






--- 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.