9. Ensuring Data Integrity : Database Events : How Database Events Work : Raise an Event
 
Share this page                  
Raise an Event
To raise a database event, use the RAISE DBEVENT statement from interactive or embedded SQL applications or from within a database procedure.
A session can raise any event that is owned by the effective user, and any event for which the effective user, group, role, or public has been granted the raise privilege. For more information on granting privileges, see the Security Guide.
The RAISE DBEVENT statement requires you to specify an event_name parameter, which is the same as the value you enter in the Create Database Event dialog when you create the dbevent object using VDBA.
When the RAISE DBEVENT statement is issued, the DBMS sends an event message to all applications that are registered to receive the specified database event. If no applications are registered to receive the event, raising the event has no effect.
The optional event_text parameter is a string that can be used to pass context information or program handles to receiving applications. For example, use event_text to pass the name of the application that raised the event. You can retrieve this value using INQUIRE_SQL.
The WITH [NO]SHARE parameter enables you to specify which of the applications registered to receive the event are actually notified. If you specify WITH SHARE or omit this parameter, the DBMS notifies all registered applications when the event is raised. If you specify WITH NOSHARE, the DBMS notifies only the application that raised the event (assuming the program was also registered to receive the event).
If a transaction issues the RAISE DBEVENT statement and the transaction is subsequently rolled back, event queues are not affected by the rollback. The raised event remains queued to all sessions that registered for the event. The event queue is described in Receive an Event.
For the complete statement syntax and additional information about using the RAISE DBEVENT statement, see the SQL Reference Guide.