7. OpenSQL Features : Database Events : Database Event Statements : Methods for Processing Database Events
 
Share this page                  
Methods for Processing Database Events
Three methods can be used to process database events:
Use the GET DBEVENT statement to explicitly consume each database event from the database event queue of the session. Typically, a loop will be constructed that polls for database events and calls routines that appropriately handle different database events. Get dbevent is a low overhead statement: it polls the application's database event queue and not the server.
Trap database events using the WHENEVER DBEVENT bevent statement. To display database events and remove them from the database event queue, specify WHENEVER DBEVENT SQLPRINT. To continue program execution without removing database events from the database event queue, specify WHENEVER DBEVENT CONTINUE. To transfer control to a database event handling routine, specify WHENEVER DBEVENT GOTO or WHENEVER DBEVENT CALL. To obtain the database event information, the routine must issue the INQUIRE_SQL statement.
Trap database events to a handler routine, using SET_SQL DBEVENTHANDLER. To obtain the database event information, the routine must issue the INQUIRE_SQL statement.
Note:  If your application terminates a select loop using the ENDSELECT statement, unread database events may be purged. Note that dbevents are received only during communication between the application and the DBMS server while performing SQL query statements. When notification is received, the application programmer should ensure that all database events in the database events queue are processed by using the GET DBEVENT loop, which is described below.