DB2 Version 9.7 for Linux, UNIX, and Windows

SET EVENT MONITOR STATE statement

The SET EVENT MONITOR STATE statement activates or deactivates an event monitor. The current state of an event monitor (active or inactive) is determined by using the EVENT_MON_STATE built-in function. The SET EVENT MONITOR STATE statement is not under transaction control.

Invocation

This statement can be embedded in an application program or issued through the use of dynamic SQL statements. It is an executable statement that can be dynamically prepared only if DYNAMICRULES run behavior is in effect for the package (SQLSTATE 42509).

Authorization

The privileges held by the authorization ID of the statement must include DBADM or SQLADM authority.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-SET--EVENT--MONITOR--event-monitor-name--STATE--------------->

   .-=-.                      
>--+---+--+-0-------------+------------------------------------><
          +-1-------------+   
          '-host-variable-'   

Description

event-monitor-name
Identifies the event monitor to activate or deactivate. The name must identify an event monitor that exists in the catalog (SQLSTATE 42704).
new-state
new-state can be specified either as an integer constant or as the name of a host variable that will contain the appropriate value at run time. The following may be specified:
0
Indicates that the specified event monitor should be deactivated.
1
Indicates that the specified event monitor should be activated. The event monitor should not already be active; otherwise a warning (SQLSTATE 01598) is issued.
host-variable
The data type is INTEGER. The value specified must be 0 or 1 (SQLSTATE 42815). If host-variable has an associated indicator variable, the value of that indicator variable must not indicate a null value (SQLSTATE 42815).

Rules

Notes

Examples

Example 1: Activate an event monitor named SMITHPAY.
   SET EVENT MONITOR SMITHPAY STATE = 1
Example 2: Assume that MYSAMPLE is a multiple partition database with two database partitions, 0 and 2. Partition 2 is not yet active.
On database partition 0:

   CONNECT TO MYSAMPLE;
   CREATE EVENT MONITOR MYEVMON ON DBPARTITIONNUM 2;
   SET EVENT MONITOR MYEVMON STATE 1;
MYEVMON automatically activates whenever MYSAMPLE activates on database partition 2. This occurs until SET EVENT MONITOR MYEVMON STATE 0 is issued, or partition 2 is stopped.