The SET COMPILATION ENVIRONMENT statement changes the
current compilation environment in the connection to match the values
contained in the compilation environment provided by an event monitor.
This statement changes the values of one or more special registers;
these changes, in turn, will affect the compilation of any subsequent
dynamic SQL statement.
This statement is not under transaction
control.
Invocation
The statement can be embedded
in an application program. It is an executable statement that can
be dynamically prepared.
Authorization
None required.
Syntax
.-=-.
>>-SET--COMPILATION ENVIRONMENT--+---+--host-variable----------><
Description
- host-variable
- A variable of type BLOB containing a compilation environment provided
by an event monitor. It cannot be set to null. If host-variable has
an associated indicator variable, the value of that indicator variable
must not indicate a null value (SQLSTATE 42815). If the format of
the compilation environment is incorrect, an error is returned, and
the connection settings remain unmodified (SQLSTATE 51040).
Notes
- To reset the compilation environment to the original default values,
terminate and then restart the connection. You can achieve the same
effect by issuing this statement within an SQL routine, so that any
special register changes are not reflected in the connection upon
return from that routine.
- Use the COMPILATION_ENV table function to look at the individual
elements that are contained within the compilation environment.
Examples
Example 1: Set the current
session's compilation environment to the values contained in a compilation
environment that was previously captured by a deadlock event monitor.
A deadlock event monitor that is created specifying the WITH DETAILS
HISTORY option will capture the compilation environment for dynamic
SQL statements. This captured environment is what is accepted as input
to the statement.
SET COMPILATION ENVIRONMENT = :hv1