7. OpenSQL Features : Database Events : Database Event Statements : Using GET DBEVENT
 
Share this page                  
Using GET DBEVENT
To get a database event registration, use the GET DBEVENT statement:
EXEC SQL GET DBEVENT [WITH NOWAIT | WAIT [= wait_value]];
To specify whether the GET DBEVENT statement waits for database events or checks the queue and returns immediately, specify the WITH [NO]WAIT clause. By default, GET DBEVENT checks and returns immediately.
If WITH WAIT is specified, GET DBEVENT waits indefinitely for the next database event to arrive. If WITH WAIT = wait_value is specified, GET DBEVENT returns when a database event arrives or when wait_value seconds have passed, whichever occurs first.
The following example shows a loop that processes all database events in the database event queue. The loop terminates when there are no more database events in the queue.
loop
exec sql get dbevent;
exec sql inquire_sql (:event_name =

dbeventname);
if event_name = 'event_1'
process event 1
else
if event_name = 'event_2'
process event 2
else
...
endif
until event_name = ''