Subject Re: [firebird-support] Action on disconnect
Author Helen Borrie
At 03:09 PM 12/09/2003 +0200, you wrote:
>Helen Borrie wrote:
> >>I've asked this on the Interbase newsgroup, and they say it's not
> >>possible. Can this be done with FireBird? If not, wouldn't this be a
> >>useful (and simple) thing to implement?
> >>
> >>
> >
> >I don't know. What would be trapped? Who or what would trap it? What
> >would the purpose be?
> >
>Well, it would open a door of new possibilities. For example, I have an
>application in which I log all user connections and disconnections to
>the database. The way I do it is insert a row into a log table when the
>application starts up, and at shutdown, I update the record with the
>disconnection time. My problem is that when a user's connection to the
>database gets cut without the application having been closed properly
>(for example if the application hangs, or if there's a network problem),
>I have no way of updating the record, so it looks like the user is still
>So it would be nice if there was a way to trap database events (such as
>connection and disconnection) in a sort of trigger style. Something like:
> ......
>Perhaps there could also be a way to catch this event from a client
>application, but this seems to me to be less useful.

Well, you could ask on firebird-devel: someone might be interested in
looking at the idea - or someone might already be thinking about
it. Albeit there's a certain degree of resistance to adding unnecessary
bloat to our famously small-footprint server. :->

Lots of people *do* keep a log such as you describe, by having the user
application write to a log table or filesystem file on connect and
disconnect. It can be a "boilerplate" module that you can compile with any
of your client apps, to run silently at logon and logoff. Obviously that
won't catch the ones that crash out or drop off the network. Of course, the
server does already log lost connections in firebird.log.