SET CURRENT SQLID

The SET CURRENT SQLID statement assigns a value to the CURRENT SQLID special register.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared. The value to which special register CURRENT SQLID is set is used as the SQL authorization ID for dynamic SQL statements only if DYNAMICRULES run behavior is in effect. The CURRENT SQLID value is ignored for the other DYNAMICRULES behaviors.

Authorization

Start of changeThe specified value must be equal to one of the authorization IDs of the application process. This rule always applies, even when SET CURRENT SQLID is a static statement.
Exception: If any of the authorization IDs of the process has SYSADM authority, CURRENT SQLID can be set to any value when the SEPARATE SECURITY system parameter is set to NO. Note that the SEPARATE_SECURITY subsystem parameter does not apply to or affect users with installation SYSADM authority.
End of change

CURRENT SQLID cannot be set to the name of a role.

Syntax

Read syntax diagram
>>-SET CURRENT SQLID--=--+-+-SESSION_USER-+-+------------------><
                         | '-USER---------' |   
                         +-string-constant--+   
                         '-host-variable----'   

Description

The value of CURRENT SQLID is replaced by the value of SESSION_USER, string-constant, or host-variable. The value specified by a string-constant or host-variable must be a character string that contains 8 characters or less. Unless some authorization ID of the process has SYSADM authority, the value must be equal to one of the authorization IDs of the process.

Notes

Effect on authorization IDs: SET CURRENT SQLID does not change the primary authorization ID of the process.

If the SET CURRENT SQLID statement is executed in a stored procedure or user-defined function package that has a dynamic SQL behavior other than run behavior, the SET CURRENT SQLID statement does not affect the authorization ID that is used for dynamic SQL statements in the package. The dynamic SQL behavior determines the authorization ID. For more information, see DYNAMICRULES bind option.

Effect on special register CURRENT PATH: When the value of the PATH special register depends on the value of the CURRENT SQLID special register, any changes to the CURRENT SQLID special register are not reflected in the value of the PATH special register until a commit operation is performed or a SET PATH statement is issued to change the SQL path to use the new value of the CURRENT SQLID.

DRDA classification: SET CURRENT SQLID is executed by the database server and is therefore classified as a non-local SET statement in DRDA.

Examples

Example 1: Set the CURRENT SQLID to the primary authorization ID.
   SET CURRENT SQLID = SESSION_USER;