The WAIT EVENT statement makes procedures to wait for an event to happen. You can use WAIT EVENT with both system-defined events and user-defined events.
If you want to stop the stored procedure waiting for an event, you can use ODBC function SQLCancel() called from a separate thread in the client application. This function cancels executing statements. Alternatively, you can create a specific user event and send it. The waiting stored procedure must be modified to wait for this additional event. The client application recognizes this event and exits the waiting loop.
Tip: With system events, you may also wait on an event without using a stored procedure by using the ADMIN EVENT statement. However, you cannot post events using ADMIN EVENT.