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
No authorization is required to execute this statement.
Syntax
.-=-. >>-SET--CURRENT--EXPLAIN--SNAPSHOT--+---+----+-NO------------+->< +-YES-----------+ +-EXPLAIN-------+ '-host-variable-'
Description
The EXPLAIN SNAPSHOT facility is intended for use with Visual Explain.
Notes
Explain snapshots for static SQL statements can be captured by using the EXPLSNAP option of the PREP or BIND command. If the ALL value of the EXPLSNAP option is specified, and the CURRENT EXPLAIN SNAPSHOT register value is NO, Explain snapshots will be captured for dynamic SQL statements at runtime. If the value of the CURRENT EXPLAIN SNAPSHOT register is not NO, then the EXPLSNAP option is ignored. For more information on the interaction between the EXPLSNAP option and the CURRENT EXPLAIN SNAPSHOT special register, see Table 144.
If the Explain snapshot facility is activated, the current authorization ID must have INSERT privilege for the Explain tables or an error (SQLSTATE 42501) is raised.
For further information, see the Administration Guide.
Example
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;