DB2 Version 9.7 for Linux, UNIX, and Windows

SET CURRENT EXPLAIN SNAPSHOT statement

The SET CURRENT EXPLAIN SNAPSHOT statement changes the value of the CURRENT EXPLAIN SNAPSHOT special register. It is not under transaction control.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

None required.

Syntax

Read syntax diagramSkip visual syntax diagram
                                 .-=-.                      
>>-SET CURRENT EXPLAIN SNAPSHOT--+---+--+-NO------------+------><
                                        +-YES-----------+   
                                        +-EXPLAIN-------+   
                                        +-REOPT---------+   
                                        '-host-variable-'   

Description

NO
Disables the Explain snapshot facility. No snapshot is taken. NO is the initial value of the special register.
YES
Enables the Explain snapshot facility, creating a snapshot of the internal representation for each eligible dynamic SQL statement. This information is inserted in the SNAPSHOT column of the EXPLAIN_STATEMENT table.

The EXPLAIN SNAPSHOT facility is intended for use with Visual Explain.

EXPLAIN
Enables the Explain snapshot facility, creating a snapshot of the internal representation for each eligible dynamic SQL statement that is prepared. However, dynamic statements are not executed.
REOPT
Enables the Explain facility and causes Explain information to be captured for a static or dynamic SQL statement during statement reoptimization at execution time; that is, when actual values for the host variables, special registers, global variables, or parameter markers are available.
host-variable
The host-variable must be of data type CHAR or VARCHAR and the length of its contents must not exceed 8. If a longer field is provided, an error will be returned (SQLSTATE 42815). The value contained in this register must be either NO, YES, or EXPLAIN. If the actual value provided is larger than the replacement value specified, the input must be padded on the right with blanks. Leading blanks are not allowed (SQLSTATE 42815). All input values are treated as being case-insensitive. If host-variable has an associated indicator variable, the value of that indicator variable must not indicate a null value (SQLSTATE 42815).

Notes

Examples

Example 1:  The following statement sets the CURRENT EXPLAIN SNAPSHOT special register, so that an Explain snapshot will be taken for any subsequent eligible dynamic SQL statements and the statement will be executed.
   SET CURRENT EXPLAIN SNAPSHOT = YES
Example 2:  The following example retrieves the current value of the CURRENT EXPLAIN SNAPSHOT special register into the host variable called SNAP.
   EXEC SQL VALUES (CURRENT EXPLAIN SNAPSHOT) INTO :SNAP;