Using User-defined Database Event Handlers
To define your own database event-handling routine, use the EXEC SQL SET_SQL(DBEVENTHANDLER) statement. This method traps database events as soon as they are added to the database event queue; the WHENEVER method must wait for queries to complete before it can trap database events. For more information, see the Set_sql section in the chapter “SQL Statements.”