Subject Re: [firebird-support] Newbee to events - how to know which record changed
Author Martijn Tonies
Hello Maya,

> I'm starting to use events for the first time, and decided to start by
> experimenting on our inhouse bug tracker.
>
> First project - trigger an event when a task has been completed, then
> detect this event and mail the appropriate people.
>
> Thanks to the info from Helen's trusty "The Firebird Book" I have put
> the following code in the Before Update trigger on my Tasks table:
>
> if ((old."DateTested2" is null) and (New."DateTested2" is not null))
> then
> post_event 'task_completed';
>
> Next I fired up my Delphi, and added the components to detect the event,
> but all I have available to me is the event name, and a counter.
>
> My question is, how do I know what record triggered the event? Is there
> any way of passing additional data through to the application?

Well, there's a problem :-) As far as I know, you cannot use wild-cards
when registering an event name, however, so posting an event like:
post_event 'task_completed.432' doesn't make sense.

However, instead of statically registered events like "task_completed",
you -know- which record you're updating, or executing a long running
process, you can registered for a specific named event.

> If I do a query for all tasks completed today, I'll possibly get more
> than one back, and the list will get longer as the day goes on.

In that case, post the event ID to a separate table that you can query
after the event is received.

> I presume I need to have some kind of an event logging table and insert
> the relevant information in there. In which case, I don't even need
> events at all anyway?? (OK, maybe just one event on my EventLog table
> every time a record is inserted to save me polling it periodically)

Exactly.

> I'm getting the feeling I might be missing the whole point of Firebird
> events?

It depends on what you want to use them for. :-)


With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com