Setting the value of OPTCOMPIND within a session

You can set or change the value of OPTCOMPIND within a session for different kinds of queries. To do this, use the SET ENVIRONMENT OPTCOMPIND statement, not the OPTCOMPIND configuration parameter or the OPTCOMPIND environment variable.

For a DSS query, you should set the value of OPTCOMPIND to 2 or 1, and you should be sure that the isolation level is not set to Repeatable Read. For an OLTP query, you could set the value to 0 or 1 with the isolation level not set to Repeatable Read.

The value that you enter using the SET ENVIRONMENT OPTCOMPIND command takes precedence over the default setting specified by the OPTCOMPIND environment variable or by the OPTCOMPIND configuration parameter in the ONCONFIG file. The default OPTCOMPIND setting is restored when the routine that issued the SET ENVIRONMENT OPTCOMPIND statement exits, or until the same routine resets the value of OPTCOMPIND to the system default by issuing the following statement:
SET ENVIRONMENT OPTCOMPIND DEFAULT;

No other user sessions or routines are affected by SET ENVIRONMENT OPTCOMPIND statements that you execute, because their scope is local to the routine in which they are issued, rather than the entire session.